sorting

How do I return an array with the initial letters of all the objects in another array?

I am working on converting a plain tableview to a sectioned tableview. I would like the section titles to be the first letter for the items in the section. This is what I have so far in my titleForHeaderInSection method: NSSortDescriptor *sortDescriptor; sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"Name" asce...

Sorting SQL table

Hi, can anyone help me with T-SQL to sort this table ID Comment ParentId -- ------- -------- 3 t1 NULL 4 t2 NULL 5 t1_1 3 6 t2_1 4 7 t1_1_1 5 to look like this ID Comment ParentId -- ------- -------- 3 t1 NULL 5 t1_1 3 7 t1_1_1 5 4 t2 NULL 6 t2_1 4 Kind regar...

how take distinct node count in xsl?

Hi Friends, test.xml <ServiceHotel> <AvailableRoom> <HotelOccupancy> <RoomCount>1</RoomCount> <Occupancy> <AdultCount>2</AdultCount> <ChildCount>1</ChildCount> </Occupancy> </HotelOccupancy> <HotelRoom> <Board>AFULL BOARD</Board> <RoomType>DOUBLE / TWIN STANDARD</RoomType> ...

Sorting by Color

I have a long list (1000+) of hex colors broken up in general color categories (Red, Orange, Blue, etc). When I show the list of colors in each category I need to show them in order of shade. i.e. light red first and dark red last. What would the algorithm be to do this? (googling has failed me) ...

How would I do a nested sort in MATLAB?

I am looking to do a nested sort with a matrix in MATLAB. Say my matrix looks like this: [b a; b c; a c; a a] I would like to first sort by the first column and maintain that sort, then sort by the second column. The result would be: [a a; a c; b a; b c] How would it be done? ...

Php Merging Arrays on Date

I have two arrays which I'm trying to merge based on the date of them. Here is what the arrays look like: $a[0][0] = '11/15/08'; $a[0][1] = '50'; $a[1][0] = '11/20/08'; $a[1][1] = '75'; $a[2][0] = '01/04/09'; $a[2][1] = '23'; $a[3][0] = '01/09/09'; $a[3][1] = '92'; and $b[0][0] = '01/04/09'; $b[0][1] = '30'; $b[1][0] = '01/05/09'; $...

Why do I get “uninitialized value” warnings when I use Date::Manip’s UnixDate in a sort block?

Related/possible duplicate: http://stackoverflow.com/questions/1263943/why-do-i-get-uninitialized-value-warnings-when-i-use-datemanips-sortbylength This block of code: my @sorted_models = sort { UnixDate($a->{'year'}, "%o") <=> UnixDate($b->{'year'}, "%o") } values %{$args{car_models}}; kept generating the following err...

Save Silverlight DataGrid sort

I have a Silverlight 2.0 DataGrid that contains a list of items that needs to be refreshed in an interval to display the up-to-the-minute information. There are items in this grid that may be added and may be removed while the screen is being displayed to the current user. For Example: If grid looks like the following, then after a m...

Sort items with minimal renumber

I need to quickly save a re-ordered sequence back to my items' integer sortOrder columns. The simple renumber-by-one approach can be slow - if last item moved to first, all N rows are modified. A multi-row update statement would let database do the work, but I'd like to explore smarter ways, like making sortOrder floating point except...

How can I sort in (n)hibernate on a property of a child object?

I have an object from my domain model that has a child object. How can I use a criteria query to order based on a property of the child? For example: class FooType { public int Id { get; set; } public string Name { get; set; } public BarType Bar { get; set; } } class BarType { public int Id { get; set; } public st...

How To... Sort 4 x 1D arrays?

I have four arrays all containing related data, Data Example:= (Array 1 | Array 2 | Array 3 | Array 4) R.E.M.|In Time: The Best Of R.E.M. 1988-2003|album:6G5BGhEiLvck3kvKpSYw2y|Rock Nick Drake|Family Tree|album:2euLAROPTmXDIDuU3qVMkf|Folk Sonic Youth|Dirty|album:0QPkL6ap8riBoQ5xN8YDR3|Noise Rock I would like to sort all arrays; filt...

How can I find the smallest value in a Perl hash of hashes of arrays?

I want to find the easiest way of finding the hash values City { city1 -> Street1 -> [ high_street , 2] street2 -> [ low_street , 2] city2 -> Street1 -> [ high_street1 , 2] street2 -> [ low_street2 , 2] city3 -> Street1 -> [ high_street1 , 1] street2 -> [ low_street2 , 1] } This structure is sor...

Radix Sort implemented in C++

UPDATE: I managed to re-work my code from scratch, and here is what I came up with. It works, but the only problem is speed. Is there any way that I can speed up my current set up using better memory management? If so, what would be the best approach? #include <iostream> #include <vector> #include <math.h> using namespace std; void pri...

Flex sorting of XMLListCollection subelements

In a Flex webapp, is there an easy way to go about applying a sort to the children of an XML element, based on the children's attributes? Example follows below: XMLListCollection: <a anotherProp="ABCDE">   <e prop="AB">1</element>   <e prop="BC">2</element> </a> <a anotherProp="FGEH">   <e prop="HF">3</element> ...

Sort a CSV file by last name with PHP

How would I sort the following CSV file using PHP? I would like to sort by last name. Do I use regex somehow to get the first letter in the last name? Any help is appreciated Here is an excerpt of my CSV file - with a ";" delimiter between names and addresses John C. Buckley, M.D.;123 Main Street, Bethesda MD 20816 Steven P. Wood;34...

Fast stable sort for small arrays (under 32 or 64 elements)

The common wisdom says that for small enough arrays insertion sort is the best. E.g., Timsort uses (binary) insertion sort for arrays up to 64 elements; from Wikipedia: Some divide-and-conquer algorithms such as quicksort and mergesort sort by recursively dividing the list into smaller sublists which are then sorted. A useful optimi...

Sorting XML nodes based on DateTime attribute C#, XPath (refer to an old post)

Hello everybody. I'm referring to this old post: http://stackoverflow.com/questions/344737/sorting-xml-nodes-based-on-datetime-attribute-c-xpath I put my question today (it is visible in the bottom) but I'm afraid it won't be visible since the post is old... so I'm asking as new question... I tryed a piece of code by Timothy Khouri bu...

Natural sort algorithm implementation woes

I have Googled ASP Classic implementations of the natural sort algorithm to no avail. Best I was able to find was from Dave Koelle, which was from a question on SO. Issue is that since I need to implement this algorithm in ASP Classic, I don't have access to certain functions such as Collections.sort(your list, new AlphanumComparator())...

Sort file beginning at a certain line

I'd like to be able to sort a file but only at a certain line and below. From the manual sort isn't able to parse content so I'll need a second utility to do this. read? or awk possibly? Here's the file I'd like to be able to sort: tar --exclude-from=$EXCLUDE_FILE --exclude=$BACKDEST/$PC-* \ -cvpzf $BACKDEST/$BACKUPNAME.tar.gz \ /etc...

Objectdatasource and Gridview : Sorting, paging, filtering

Hi there, Im using entity framework 1.0 and trying to feed out a Gridview with a objectdatasource that have access to my facade. The problem is, that it seems to be particulary difficult and haven't seen anything that realy do what i want it to do on the internet. For those who know, a gridview feeded with an objectdatasource, it can'...