sorting

How to sort an NSMutableArray List of objects in alphabetical order.

Hi guys, I have an object with different values that is name,nameid, lifebeging,lifeEndiging .... etc, for loop { // here i will get name, ids, other value for each object Search *Obj=[artistslist objectAtIndex:i]; } 0 obj.name= //string values1 get from parser 1 obj.name= //string values1 2 obj.name= //string values1 3 ...

Sort files (strings) over 4 arrays

Hi there, I am after a function which will let me sort a bunch of filenames over 4 arrays. However, the a file must always end up in the same array - even if the number of files change. Eg if I have files myfile.html anotherfile.html morefiles.html test.html and my arrays array1, array2, array3, array4 If I run this function then ar...

How to sort an array of structs in ColdFusion

I have an array of structs in ColdFusion. I'd like to sort this array based on one of the attributes in the structs. How can I achieve this? I've found the StructSort function, but it takes a structure and I have an array. If this is not possible purely in ColdFusion, is it possible in Java somehow (maybe using Arrays.sort(Object[], Co...

barebones sort algorithm

i have been asked to make a simple sort aglorithm to sort a random series of 6 numbers into numerical order. However i have been asked to do this using "Barebones" a theoretical language put forward in the Book Computer Science an overview. Some information on the language can be found here http://www.brouhaha.com/~eric/software/barebo...

Java Collections Sort not accepting comparator constructor with arg

I'm getting a compiler error for this line: Collections.sort(terms, new QuerySorter_TFmaxIDF(myInteger)); My customized Comparator is pretty basic; here's the signature and constructor: public class QuerySorter_TFmaxIDF implements Comparator<Term>{ private int numberOfDocs; QuerySorter_TFmaxIDF(int n){ super(); numberOfDocs ...

A good Sorted List for Java

I'm looking for a good sorted list for java. Googling around give me some hints about using TreeSet/TreeMap. But these components is lack of one thing: random access to an element in the set. For example, I want to access nth element in the sorted set, but with TreeSet, I must iterate over other n-1 elements before I can get there. It wo...

Using a locale-dependent sorting function in Ruby/Rails

What is a good approach to sorting an array of strings in accordance with the current locale? For example the standard Array#sort puts "Ä" after "Z", which is not correct in German. I would have expected the gem I18n to offer a hook for defining my own sorting algorithms or providing collation strings or objects. In my imagination, pas...

How to sort list of object.name in alphabetical order using custom compare in objective-C?

Hi Guys, I am not getting the idea to sort names from each object in the list , please help me. for(int i=0;i<[artistsList count];i++) { Search *obj=[artistsList objectAtIndex:i]; // It is not correct way,I am just explaining the problem [artistsList sortUsingSelector:@selector(myCustomCompare:obj.name)]; } I need custom method to sor...

sort files by date in PHP

hi, I currently have an index.php file which allows me to output the list of files inside the same directory, the output shows the names then I used filemtime() function to show the date when the file was modified. my problem now is, how will I sort the output to show the latest modified file ?, I've been thinking for awhile how to do th...

Form to sort an index in rails

I'm a newcomer to Rails. I want to build a simple form that determines the sort order of a list. I've implemented a form in the likes of - <%= radio_button_tag :sort, "rating" %> <%= label_tag :sort_rating, "order by rating" %> <%= radio_button_tag :sort, "name" %> <%= label_tag :sort_name, "order by name" %> And now I am unsure h...

How to sort alpha numeric set in python

Hi folks, I have a set set(['booklet', '4 sheets', '48 sheets', '12 sheets']) After sorting I want it to look like 4 sheets, 12 sheets, 48 sheets, booklet Any idea please ...

XSLT Sort Alphabetically & Numerically Problem

I have a group of strings ie g:lines = '9,1,306,LUCY,G,38,12' I need the output to be in XSLT 1.0: 1,9,12,38,306,G,LUCY This is my current code: <xsl:for-each select="$all_alerts[g:problem!='normal_service'][g:service='bus']"> <xsl:sort select="g:line"/> <xsl:sort select="number(g:line)" data-type="number"/> <xsl:value-of selec...

Sorting nested hash in ruby

Provided the following ruby hash: { cat: { 1: 2, 2: 10, 3: 11, 4: 1 }, wings: { 1: 3, 2: 5, 3: 7, 4: 7 }, grimace: { 1: 4, 2: 5, 3: 5, 4: 1 }, stubborn: { 1: 5, 2: 3, 3: 7, 4: 5 ...

NSArray from NSSet - Do I have to sort it myself?

I've got data in an NSSet, and I need to get it into an NSArray. Do I need to sort it myself (again, this came from Core Data) or can I get it out in a sorted order? ...

Sort an array by a child array's value in PHP

I have an array composed of arrays. I want to sort the parent array by a property of the child arrays. Here's an example array(2) { [0]=> array(3) { [0]=> string(6) "105945" [1]=> string(10) "First name" [2]=> float(0.080878465391) } [1]=> array(3) { [0]=> string(6) "109145" [1]=> stri...

Sorting Dynamically generated HTML Table

I am generating a dynamic HTML table string and displaying inside a div. I am assigning ID and runat server in that string. eg. string s="<table id='tblAll' runat='server'></table>". This string is generated on some different page, and its passed as XmlhttpResponseText I want to apply sorting on this table, It would be great if any o...

How to sort a multi-dimensional array by a 4th level value in PHP

I have an array which is converted from an XML response. What I need to do is sort the array ascending alphabetically using the 'COMPANY' value. I have attempted to use array_multisort, but I'm having no luck at all. Any help would be greatly appreciated. Here is the array: array(1) { ["DATASOURCE"]=> array(1) { ["MEMBER"]=> ...

Black box test cases for insertion procedure

insertion_procedure (int a[], int p [], int N) { int i,j,k; for (i=0; i<=N; i++) p[i] = i; for (i=2; i<=N; i++) { k = p[i]; j = 1; while (a[p[j-1]] > a[k]) {p[j] = p[j-1]; j--} p[j] = k; } } What would be few good test cases for this particular insertion procedure? ...

How to sort output of "s3cmd ls"

Amazon "s3cmd ls" takes like this output: 2010-02-20 21:01 1458414588 s3://file1.tgz.00 2010-02-20 21:10 1458414527 s3://file1.tgz.01 2010-02-20 22:01 1458414588 s3://file2.tgz.00 2010-02-20 23:10 1458414527 s3://file2.tgz.01 2010-02-20 23:20 1458414588 s3://file2.tgz.02 How to select all files of archive, ending at 00 ... XX...

Why is my List.Sort method in C# reversing the order of my list?

I have a list of items in a generic list: A1 (sort index 1) A2 (sort index 2) B1 (sort index 3) B2 (sort index 3) B3 (sort index 3) The comparator on them takes the form: this.sortIndex.CompareTo(other.sortIndex) When I do a List.Sort() on the list of items, I get the following order out: A1 A2 B3 B2 B1 It has obviously worked...