sorting

Sort N numbers in digit order

I found out about this question recently. Given a N number range Eg. [1 to 100], sort the numbers in digit order (i.e) For the numbers 1 to 100, the sorted output wound be 1 10 100 11 12 13 . . . 19 2 20 21..... 99 This is just like Radix Sort but just that the digits are sorted in reversed order to what would be done in a normal Radix...

How do you sort parrallel arrays in Perl?

Hi, I have a few arrays of the same length. I want to sort the first array, and make all the others array "sort" accordingly. For example, if the first array is (7,2,9) the second is ("seven","two","nine") and the third is ("VII","II","IX") after the sort (ascendingly according to the first array values) we will have (2,7,9) ("two","sev...

Help Sorting NSArray

In my project I roll through a bunch of sql records and populate a NSMutableDictionary with a string for each key. The keys are important because I use them as section titles in my TableView. The problem I have is that I would like the sections in a certain order. When I call allKeys the order of the keys isn't the same as the order the...

Sort & uniq in Linux shell

What is the difference between the following to commands? sort -u FILE sort FILE | uniq Thanks! ...

Core Data: Sort to-many relationship in NSTableView

Hello experts, I have troubles getting my NSTableView keep the contents of a to-many relationship ordered. What I have is an entity "Relationship" in a to-many relationship with an entity "Card" both managed by an NSArrayController. Card has 2 attributes, "number" (int) and "name" (String) displayed via Bindings in two columns of a NS...

iPhone - creating a tableview sectioned and in alphabetical order

I am pretty new to programming any sort of device and am on a steep learning curve, so please forgive me if this doesnt make too much sense or the code in the question is awful - we all ave to start somewhere, and beleive me, i have read and read and read! I am creating a table from a plist which is an array of dictionarys - i need it i...

How to express "or" in a dictionary queryset in django

I'm filtering a big number of users based on attributes. For example, they can be filtered by minimum gpa. So far I've been doing the following to construct my queryset- ('gpa_gt' just means that the gpa property has to be greater than whatever is the query param) if len(request.GET) != 0: kwargs = {} if request.GE...

Sorting a list of lists in Python

c2=[] row1=[1,22,53] row2=[14,25,46] row3=[7,8,9] c2.append(row2) c2.append(row1) c2.append(row3) c2 is now: [[14, 25, 46], [1, 22, 53], [7, 8, 9]] how do i sort c2 in such a way that for example: for row in c2: sort on row[2] the result would be: [[7,8,9],[14,25,46],[1,22,53]] the other question is how do i first sort by ro...

Why isn't natsort (or natcasesort) working here?

Perhaps I'm doing something embarrassingly wrong, but why isn't this array being sorted? $narray=array(); $dir_handle = @opendir($path.$projectFolder) or die("Unable to open $path$projectFolder"); $i=0; while($file = readdir($dir_handle)) { $filenameSplit = explode('.',$file); if ($file != "." && $file != ".." && $filenameSplit[0...

Sort by proxy (or: sort one container by the contents of another) in C++

I have a set of data which is split into two arrays (let's call them data and keys). That is, for any given item with an index i, I can access the data for that item with data[i] and the key for that item with keys[i]. I cannot change this structure (eg, to interleave keys and data into a single array), because I need to pass the data ar...

SQL Sort Order by The Order Specified In the Query

Say I have a query "select * from clauses where id in (0,2,5,1,3)" and I actually want the rows returned in the same order they are specified the where clause. The order of the IDs will change from query to query and there is no pattern to the order. I know it's possible to alter the data model, create temp tables, etc. But trust me ...

need help with sort function in python

Hi, The contents of my dictionary is like so:- >>> dict {'6279': '45', '15752': '47', '5231': '30', '475': '40'} I tried using the sort function on the keys. I noticed that the sort function doesn't work for the key -- 15752. Please find below:- >>> [k for k in sorted(dict.keys())] ['15752', '475', '5231', '6279'] Could someone po...

std::sort on std::vector<std::string>

Hello, I have a std::vector<std::string> which would contain numbers and characters (single char). I would want to have numbers sorted first followed by the characters...so I have a jumbled up vector of strings as an input and after sort I want it like 1,2,3,5,7,9,10,A,B,C,D. But I guess sort also compares the sizes of the inputs, and h...

How to sort a NSArray randomly?

Let's say I have a NSArray with 50-100 objects inside. How can I sort the array into a random order? ...

How to sort Sharepoint discussion thread by the number of Replies

Since this isn't available OOB, I tried sorting the discussion list using Sharepoint Designer, converting "Replies" to number using XPath..but it sorts it like a string (e.g., 1, 10, 11, 2, 3, 4, 5, and so on...). How do sort by number of replies properly? ...

Is it possible conditional sort in hash

Is it possible conditional sort in hash my hash like {1=>"10",2=>"20",3=>"30",4=>"40",5=>"50",6=>"60",7=>"70",8=>"80",9=>"90"} wanted result is {7=>"70",8=>"80",9=>"90",1=>"10",2=>"20",3=>"30",4=>"40",5=>"50",6=>"60"} add condition in this code operation_hour_hash.sort{|key,value| key[1]<=>value[1]} ...

Table scrollbar without changing headers and provide sorting in headers

Hello All, Here is mytable and need the headers to remain while there is a scrollbar only to the results and provide the sorting facility in the name. <table> <tr> <td>id</td> <td>name</td> <td>type</td> </tr> <% while(resultSet.next()) { %> <tr> <td><%=resultSet.getString...

sorting in keil

i am supposed to code a bubble sort program in embedded C using keil uVision. I havnt yt understood what is it that is actually required. I have been told to use registers and/or ports in it. if anyone can understand what exactly has to be done pls help me out... ...

NSTableView: Avoid Blue Header when Sorting Table Column

Hey experts, when I click on the header of an NSTableView column, the header gets blue and the little grey arrow shows up. How do I avoid the blue selection and the arrow (but keeping the sorting itself)? As an example for what I want: In Xcode click on the 'Groups & Files' header. Thank your for any help! ...

Sort XML file based on XSD format in .Net

I have a requirement to generate XML, validate against an XSD and (if valid), send the XML to a third party. My problem is that generating the nodes of the XML file in the correct order (as the XSD defines it) is very difficult with my current scenario. Writing the code to manually add the nodes in the correct order would mean a lot of ...