basically I have a bunch of files containing domains. I've sorted each individual file based on its TLD using .sort(key=func_that_returns_tld)
now that I've done that I want to merge all the files and end up wtih one massive sorted file. I assume I need something like this:
open all files
read one line from each file into a list
sort l...
I am using Python 2.6 and I have two data stores. Querying the first one returns a list of document IDs in a specific order. I look up all the documents at once in the second data store using these IDs, which returns a list of dictionaries (one for each doc), but not in the same order as the original list. I now need to re-sort this list...
I have an NSMutableArray of Sprites and I want to remove a few of them based on their proximity to another sprite. So say I have 10 sprites and I want to remove the first 3 that are closest to another sprite.
I can't think of a sophisticated efficient way of doing this, anything i've come up with so far seems overly convoluted and ineff...
this is similar to the question in http://stackoverflow.com/questions/3559807/merge-sort-in-python
I'm restating because I don't think I explained the problem very well over there.
basically I have a series of about 1000 files all containing domain names. altogether the data is > 1gig so I'm trying to avoid loading all the data into r...
In [1]: l1 = ['a',2,3,0,9.0,0,2,6,'b','a']
In [2]: l2 = list(set(l1))
In [3]: l2
Out[3]: ['a', 0, 2, 3, 6, 9.0, 'b']
Here you can see the the list l2 is falling with different sequence then the original l1, I need to remove the duplicate elements from my list without changing the sequence/order of the list elements....
...
void merge(vector<int> dst,vector<int> first,vector<int> second)
{
int i=0,j=0;
while(i<first.size()&&j<second.size())
{
if(first[i]<second[j])
{
dst.push_back(first[i]);
i++;
}
else
{
dst.push_back(second[j]);
j++;
}
}
wh...
var obj = {
'51' : { 'name':'name1'},
'66' : { 'name':'name2'},
'58' : { 'name':'name3'}
};
$(function() {
s = '';
$.each(obj, function(k, v) {
s += ' '+k;
});
alert(s);
});
In IE and Firefox it's 51 66 58, but in Opera and Chrome it's 51 58 66
Why Jquery.each() sort by key in opera, chrome?
What can i...
Hello,
I would like to sort some objects that have a Name property. These objects are stored in CollectionViewSource. I add sorting description in the following way:
MyCollectionViewSource.View.SortDescriptions.Add(new SortDescription("Name"),direction));
where direction is Ascending/Descending.
Everything works fine except one case...
I found that java.util.Arrays.sort(Object[]) use 2 kinds of sorting algorithms(in JDK 1.6).
pseudocode:
if(array.length<7)
insertionSort(array);
else
mergeSort(array);
Why does it need 2 kinds of sorting here? for efficiency?
...
I have a gridview that is bound to a datatable. I have also written some c# code to sort and page that gridview. However, the buttonfield column is not being sorted with the rest of the table. How would I accomplish this?
Current Sorting Code:
protected void gridView_SortingUser(object sender, GridViewSortEventArgs e)
{
...
Hello everyone,
I have an array which contains the following numbers:
10000
900
670
600
500
I want to sort the array in that format above. Largest to smallest, thus using rsort().
However the outcome turns out to be:
900
670
600
500
10000
Looks like rsort() just looks at the first digit of the whole number to sort the array. Is th...
I want to sort the words on lines in a file line by line and I want the ouptut to be lines with the words sorted alphabetically.
for example:
queue list word letter gum
another line of example words
...
I want the output to be:
gum letter list queue word
another example line of words
...
I can't seem to get it to wo...
print "@_\n";
4109 4121 6823 12967 12971 14003 20186
How do I sort it in Perl?
Using @sorted = sort(@_); gives me an alphabetical ordering
13041 13045 14003 20186 4109 4121 6823
How do I get a numerical ordering? Does Perl have built-in functions for merge-sort, insertion-sort etc.?
...
Possible Duplicate:
Sort a matrix with another matrix
Given two matrices A and B of the same size, I want to sort A across the second dimension (rows) and apply the same ordering to the matrix B. Is it possible to vectorize this current code?
r = 10; c = 4;
A = rand(r,c);
B = reshape(1:r*c,c,r)'; % can be any random matrix'
...
I have a number of directories containing the files similar to the below example:
test
setup
adder
hello
_CONFIG
TEST2
The file(s) in these directories with the prefix _ represent configuration files of significance. The aim was to have these files appear first when I listed the directory i.e. I would like to be provided with:
_CONFI...
hi there
I have a little web app, that consumes a web service. the main page runs a search - by passing params to a particular ws method, and then i bind the results to a gridview.
I have implimented sorting and paging on the grid, by putting the datatable that the grid is bound to in the viewstate and then reading/sorting / filtering ...
Ok I have two files in Excel 2007. They are both to large to do this sort manually consisting of several thousand lines.
File 1 has first names and ID numbers as 2 columns:
Joe 1
Mark 2
Bob 3
Sally 4
etc...
File 2 has last names and ID number as 2 columns:
Smith 1
Johnson 2
Brown 3
Hands 4
Is there an easy way where I can sort these ...
I'm writing an implementation of an R-Tree based on Guttman's original paper. I was thinking about using an R-Tree for a program I'm writing that involves a lot of rectangles on the screen that can be moved/re-sized with the mouse.
I want to efficiently only select rectangles that are in a particular rectangle and draw them (instead of...
Hi there,
Thank you for taking the time to read this and I will appreciate every single response no mater the quality of content. :)
Using php, I'm trying to create a script which will numerically sort a text file (.txt) in ascending order (lowest to highest). Each entry within the text file is on a new line, therefore I'd like the lin...
What is an elegant way to take a javascript array, order by the frequency of the values, and then filter for uniques?
So,
["apples", "oranges", "oranges", "oranges", "bananas", "bananas", "oranges"]
becomes
["oranges, "bananas", "apples"]
...