sorting

Sort by an object's type

Hi all, I have code that statically registers (type, handler_function) pairs at module load time, resulting in a dict like this: HANDLERS = { str: HandleStr, int: HandleInt, ParentClass: HandleCustomParent, ChildClass: HandleCustomChild } def HandleObject(obj): for data_type in sorted(HANDLERS.keys(), ???): if isinstan...

Confused about GNU `sort(1)` of a numerical sub field

I wish to sort a space separated table, with the numerical value that found on the 2nd field. I can assume that the 2nd field is always fooN but the length of N is unknown: antiq. foo11 girls colleaguing foo2 Leinsdorf Cousy foo0 Montgomeryville bowlegged foo1 pollack Chevrier foo10 ill-conceived candlebomb foo3 seventieths autochthony ...

sorting a doubly linked list with merge sort.

Hi I have found this code in the internet and it was for arrays ,I want to change it for doubly linked list(instead of index we should use pointer) would you please help me that how can i change merge method(I have changed sort method by myself) also this is not my home work ,I love working with linked list!! public class MergeSort { p...

Array of pointers in Objective-C using NSArray

Hello, I am writting program for my iphone and have a qestion. lets say i have class named my_obj class my_obj { NSString *name; NSinteger *id; NSinteger *foo; NSString *boo; } now i allocate 100 objects from type my_obj and insert them to array from type NSArray. then i want to sort the Array in two diffe...

Sorting shell items like windows explorer

Hi, I am making a bread crumb bar in Delphi and having some problems regarding sorting the dropdown of the bread crumbs. Strangely enough, even Vista is not consequent when showing these items. I have tried many ways to figure out what is system folders, what is zip files and what is normal folders. It seems like an easy task but so f...

Need to sort 3 arrays by one key array

I am trying to get 3 arrays sorted by one key array in objective c for the iphone, here is a example to help out... Array 1 Array 2 Array 3 Array 4 1 15 21 7 3 12 8 9 6 7 8 0 2 3 4 8 When sorted i...

Custom array sort in perl

I have a perl array of to-do tasks that looks like this: @todos = ( "1 (A) Complete online final @evm4700 t:2010-06-02", "3 Write thank-you t:2010-06-10", "4 (B) Clean t:2010-05-30", "5 Donate to LSF t:2010-06-02", "6 (A) t:2010-05-30 Pick up dry cleaning", "2 (C) Call Chris Johnson t:2010-06-01" ); That first number is th...

Sort the $_POST variables

Hello guys Might be an easy for you guys. I am trying to sort the $_POST variables that were sent by a form and update the sorted result in mysql. I am not sure how to do it and appreciate it anyone can help me about it. My main.php //I have a loop here. (omitted) //$k will be increased by 1 every time the loop starts, so I will kn...

how to do sorting using java

hi friends, I have text file with list of alphabets and numbers. I want to do sorting w.r.t this number using java. My text file looks like this: a--->12347 g--->65784 r--->675 I read the text file and i split it now. But i dont know how to perform sorting . I am new to java. Please give me a idea. My output want to be g--->65784 ...

php sort properties of object

I want to sort the properties of an object so I can loop through them in a defined order. for example: I have an object 'book' with the following properties: 'id', 'title', 'author', 'date'. Now i want to loop through these properties like this: foreach($book as $prop=>$val) //do something now the order of the loop has to be 'title...

maintaing a sorted list that is bigger than memory

I have a list of tuples. [ "Bob": 3, "Alice": 2, "Jane": 1, ] When incrementing the counts "Alice" += 2 the order should be maintained: [ "Alice": 4, "Bob": 3, "Jane": 1, ] When all is in memory there rather simple ways (some more or some less) to efficiently implement this. (using an index, insert-sort etc) The que...

Mysql sql how can I sort a table based on Locale?

My application is using a search function, sometimes the search may return a result set with thousands of items, therefore I am using lazy loading and only retrieving the primary keys. The problem is that my application is localized, and I need to sort this primary keys alphabetically using another column in the table that has a name t...

sort an array such that one half of the array has even numbers in ascending order and the other half has odd numbers in descending order.

Possible Duplicate: simple question regarding sorting Design an algorithm with min time and space here is my solution - assume a array of N elements with 32 bit integers use a bit array to set the appropriate bits the array is sorted now assign even numbers to the first half of the array in ascending order assign odd number...

Javascript: sort objects

function Player() { var score; this.getScore = function() { return score; } this.setScore = function(sc) { score = sc; } } function compare(playerA, playerB) { return playerA.getScore() - playerB.getScore(); } var players = []; players['player1'] = new Player(); players['player2'] = new Player(); Array(players).sort(compare)...

Drupal drag-able blocks issue

Druapl offers great functionality whereby blocks can be dragged up and down to reorder as shown below. However, on a couple of projects I've been working on they have disappeared during development )as shown below) but I have no idea why! It must be something that I am doing wrong but for the life of me I can't work out why. ...

Sorting 1000-2000 elements with many cache misses

I have an array of 1000-2000 elements which are pointers to objects. I want to keep my array sorted and obviously I want to do this as quick as possible. They are sorted by a member and not allocated contiguously so assume a cache miss whenever I access the sort-by member. Currently I'm sorting on-demand rather than on-add, but because ...

Initial state of autoCreateRowSorter in Swing JTable

I have this JTable on my Swing app with the autoCreateRowSorter enabled. My table only has 3 columns, two strings and one int, it works well for all of them when I click the column headers. However, I'm looking for way to do it programatically. I wanted to set the "initial state" for this table. With the Windows look and feel, the colum...

Help with a sort method

Hi there, If i have an array of strings for example Static final String[] TEST = new String[] { "g","a","b","t","e" }; How would i go about sorting this in alphabetical order please? ...

PHP Associative array sort

I have an array like one below. Currently it is sorted alphabetically by the OwnerNickName field. Now i want to brig the array entry with OwnerNickName 'My House' as the first entry of the array and rest sorted alphabetically by OwnerNickName. Any idea? Array ( [0318B69D-5DEB-11DF-9D7E-0026B9481364] => Array ( [O...

Sorting a directory in perl, taking numbers into account

I think I need some sort of Schwartzian Transform to get this working, but I'm having trouble figuring it out, as perl isn't my strongest language. I have a directory with contents as such: album1.htm album2.htm album3.htm .... album99.htm album100.htm I'm trying to get the album with the highest number from this directory (in this c...