sorting

Sorting list of string paths in VB.NET

Hi there, I would like to sort a list of strings which represent paths. The sort result will do have a hierarchical order. What I mean is: for each directory path, I want to list all files in that path (alphabeticaly or not doesn't matter) in first time. Then, each subdirectory path will be listed. For each subdirectory, I want all file...

How can I sort a 2-D array in MATLAB with respect to 2nd row?

I have array say "a" a = 1 4 5 6 7 2 if i use function b=sort(a) gives ans b = 1 4 2 6 7 5 but i want ans like b = 5 1 4 2 6 7 mean 2nd row should be sorted but elements of ist row should remain unchanged and should be correspondent to row 2nd. ...

Cocktail Sort code segfaults - not sure why.

Hi there. I wrote a Cocktail Sort algorithm, and am testing it by generating random vectors of size 500 up to 10,000 - running it 10 times per vector. After about the 2000-3000 length vector mark, the code segfaults. I expect it isn't the test code as the same test is used for multiple sorting algorithms and it runs fine for every other ...

How to sort an XMl using XSLT 1.0?

I'm looking for an XSL to sort and group an XML by a node and sum by another node. I will have to use XSLT 1.0. Here is my XML. After sorting I need to have a new XML sorted and Grouped by <TransCode>, and all <TransAmt> should be summed for each group. I'm looking for the XSL for this task. Any help is appreciated. After sorting n...

How to qsort an array of pointers to char in C?

Suppose I have an array of pointers to char in C: char *data[5] = { "boda", "cydo", "washington", "dc", "obama" }; And I wish to sort this array using qsort: qsort(data, 5, sizeof(char *), compare_function); I am unable to come up with the compare function. For some reason this doesn't work: int compare_function(const void *name1,...

Fast way to alphabetically sort the contents of a file in java

Can anyone recommend a fast way to sort the contents of a text file, based on the first X amount of characters of each line? For example if i have in the text file the following text Adrian Graham some more text here John Adams some more text here Then another record needs to be inserted for eg. Bob Something some more text he...

Objective-C Sort NSMutableArray of Objects by a specific Object attribute

I have an object called Station in my system with these attributes: @interface Station : NSObject { NSString *stationID; NSString *callsign; NSString *stationState; } I also have an NSMutableArray containing 20 'Station' objects as defined above. I need to define a method which can can sort this array in 2 ways: 1) By stationID 2) By...

Objective-C NSMutableArray: Problem with sorting objects?

I currently have an object called Station defined as: @interface RFStation : NSObject { NSString *stationID; NSString *callsign; NSString *logo; NSString *frequency; @end I also have an NSMutableArray containing a list of 'Station' objects. I need to have a method to sort these objects by the 'stationState' attrib...

Individual User 'top 5' lists

Hello, I am aiming to produce a individual top 5 list for each user of my drupal site. now trying to work this one out has become quite difficult and hence why i am here. what im looking for is a top 5 list which allows the user to select nodes to be ranked by the user. so at anytime the user can edit the list and re-order the list. ...

How to sort a List in C#?

I have the following List : List<Dictionary<int, Dictionary<string, string>>> lngList lngList.Add(new Dictionary<int,Dictionary<string,string>>().Add(1,new Dictionary<string,string>().Add("Item1Key","Item1Value"))); lngList.Add(new Dictionary<int,Dictionary<string,string>>().Add(3,new Dictionary<string,string>().Add("Item1Key","Item1Val...

Sorting a collection in alphabetical order

Hi, Is there any way, out of the box, to sort a collection in alphabetical order (using C# 2.0 ?). Thanks ...

Needing XSLT sort to treat some strings as numbers

Hi! I am unsure if this is an error, or if this is just how XSLT sort works. When I do the following: <xsl:apply-templates select="//*[@id&lt;=50000]"> <xsl:sort select="@id" /> </xsl:apply-templates> The results are not being sorted as if they are numbers. For example I would get the following results: @id 0 @id 1 @id -1 @id 10...

"Incompatible pointer type" compiler warning for 4th argument of qsort

I'm trying to use the standard library's qsort to sort an array of wide characters: wchar_t a = L'a'; wchar_t a1 = L'ä'; wchar_t b = L'z'; wchar_t chararray[] = {b, a, a1}; length = wcslen(chararray); qsort(chararray, length, sizeof(wchar_t), wcscoll); Now I think the functions involved have these prototypes: int wcscoll(const wch...

vb.net 3.5 treeview.sorted=false does NOT turn off sorting! why?

msdn says false is default, but whether or not I explicity set treeview1.sorted=false, it always sorts it alphabetically by the visible node text. How do I get it to stay in the order in which I load the nodes? Private Sub LoadChildren(ByVal ID As Integer, ByVal Node As TreeNode) Dim L As List(Of Integer) = DB.GetChildren(ID) ...

jQuery ordering list items up and down not with drag and drop

Hi, I want a user to be able to reorder a list on a click event. I have set up a very basic jsFiddle here: http://jsfiddle.net/8vWXZ/2/ So in this example i would like to move the clicked li item and its contents to the position above in the DOM. I suppose strictly speaking it is being moved down in the index of li items. This is g...

IComparable - Call different sorts?

I have a DTO that I am using to process transactions. To ensure that it is processing in the correct order, I am using iComparable and sorting the List(of T) of the DTO. That works great. However I just got another requirement that the customer wants the output in a different order... is there a way to allow me to have two different sort...

Sort order of table tbody in same order as list elments jquery json

I have been working on this jsFiddle and wanted to extend the functionality so that when the list items have been altered and submitted via the form then the associated table tbodys sort themselves in the same order as their list item counterparts: http://jsfiddle.net/8vWXZ/20/ Is it possible to map the order from one element to anothe...

PHP/mysql: querying MySQL with an array and getting results in an array

I have an array, $scans. I want to query MySQL with all the values in that array and get my results back in an array. For example, sample data in scans would be: E1234 E2244 E3654 The MYSQL table PARTS has fields part, size, length, plate, side, type. I want to end up with $output["E1234"][0] to be the size result for that part, 1 t...

jquery, move an inner element to the first position?

Lets say you have a list of items: <ul id="ImportantNumbers"> <li id="one"></li> <li id="two"></li> <li id="topNumber"></li> <li id="four"></li> </ul> Every five seconds these list items get reordered. Using jquery whats the best way to keep #topNumber, at the top of the list during the reordering. ...

Sorting the values in a java ConcurrentHashMap

I have the following code for sorting a ConcurrentHashMap: ConcurrentHashMap<String,String> text = new ConcurrentHashMap<String,String>(); .... List<String> list = new ArrayList<String>(text.values()); Collections.sort(list); Which throws a NoSuchElementException: Caused by: java.util.NoSuchElementException at library.ArrayL...