sorting

PHP Sort Array based on values in another.....

Possible Duplicate: PHP - sort an array based on another array? Need some help regarding array sorting.... I have two arrays. The main one (where the key is the user id) : $user[31] = 'Tom' $user[43] = 'Jane' and another array with the order they should be displayed (where key is the order and value is the user id) : $or...

C++ struct sorting

I have a vector of custom Struct that needs to be sorted on different criteria each time Implementing operator < will allow only one criteria But I want to be able to specify sorting criteria each time I call C++ standard sort. How to do that? Please note it is better to be efficient in running time.. Thanks ...

How to implement a collection (list, map?) of complicated strings in Java?

Hi all. I'm new here. Problem -- I have something like the following entries, 1000 of them: args1=msg args2=flow args3=content args4=depth args6=within ==> args5=content args1=msg args2=flow args3=content args4=depth args6=within args7=distance ==> args5=content args1=msg args2=flow args3=content args6=within ==> args5=content args1=ms...

STL map--> sort by value?

Hi I wonder how can I implement the STL map sorting by value. For example, I have a map m map<int, int>; m[1] = 10; m[2] = 5; m[4] = 6; m[6] = 1; and then.. I'd like to sort that with the m's value. So, if I print the map, I'd like to get the result like m[6] = 1 m[2] = 5 m[4] = 6 m[1] = 10 this. How can I sort like this way? Is...

multi-dimension array value sorting in php

Another potentially interesting (or n00b, whatever comes first) question. I am building up an array with a set of database fields with information about table, actual field name and descriptive field name as a multi-dimensional array. Here is what it currently looks like: $Fields['User']['ID'] = "User ID"; $Fields['User']['FirstName'] ...

C++ change sort method

Possible Duplicate: C++ struct sorting Is it possible to sort a vector in C++ according to a specified sorting method, like used in Java's Collections.sort that takes a Comparator? ...

[C++] How should I compare pairs of pointers (for sort predicate)

I have a STL container full of billions of the following objects pair<SomeClass*, SomeClass*> I need some function of the following form /*returns items sorted biggest first */ bool sortPredicate (pair<SomeClass*, SomeClass*>two, pair<SomeClass*, SomeClass*> one) { return ???; } Is there some trick I can use to very quickly com...

How to sort an NSMutableArray of objects by a member of its class, that is an int or float

I have a class (from NSObject) that contains: NSString name int position float speed I then create an array (NSMutableArray) of objects from this class. I would like to then sort the array by the 'speed' value, which is a float. I initially has the float value as an NSNumber and the int as NSInteger, and I was successfully s...

RadGrid nestedview sort makes nestedview disappear?

When I click on the header of my detail table, it disappears entirely, leaving empty white space in the browser where it used to be. The Ajax postback caused by my clicking on the header does fire FooGridNeedDataSource and FooGridItemCommand, but I've used the debugger to skip the code inside those handlers (after clicking the header of...

C# .NET: Descending comparison of a SortedDictionary?

I'm want a IDictionary<float, foo> that returns the larges values of the key first. private IDictionary<float, foo> layers = new SortedDictionary<float, foo>(new DescendingComparer<float>()); class DescendingComparer<T> : IComparer<T> where T : IComparable<T> { public int Compare(T x, T y) { return -y.CompareTo(x); ...

Is this a bad version of the Merge Sort algorithm?

merge1(int low, int high, int S[], U[]) { int k = (high - low + 1)/2 for q (from low to high) U[q] = S[q] int j = low int p = low int i = low + k while (j <= low + k - 1) and (i <= high) do { if ( U[j] <= U[i] ) { S[p] := U[j] j := j+1 } else ...

More than one unique key for HashMap problem (Java)

This question is a continuation of this thread: In short: To solve my problem, I want to use Map<Set<String>, String>. However, after I sort my data entries in Excel, remove the unnecessary parameters, and the following came out: flow content ==> content content flow content ==> content depth distance flow content ==> content depth ...

Best way to get the values of a hash ordered by their respective keys? (Ruby)

Here's what I'm doing atm: test = { 'd' => 20, 'b' => 40, 'c' => 30, 'a' => 50, 'e' => 10 } f = [] test.to_a.sort.each do |e| f << e[1] end puts f.join(' ') Outputs: 50 40 30 20 10 Is there a more efficient/concise/better way to do this? And before someone says so, no, I can't use an array. :p EDIT Sorry, posted the w...

Sorting a C# Dictionary

I have a dictionary in C# like Dictionary<Person, int> and I want to sort that dictionary in place with respect to keys (a field in class Person). How can I do it? Every available help on the internet is that of lists with no particular example of in place sorting of Dictionary. Any help would be highly appreciated! ...

Sorting a 2D numpy array by multiple axes

I have a 2D numpy array of shape (N,2) which is holding N points (x and y coordinates). For example: array([[3, 2], [6, 2], [3, 6], [3, 4], [5, 3]]) I'd like to sort it such that my points are ordered by x-coordinate, and then by y in cases where the x coordinate is the same. So the array above should look ...

Retrieve Core Data Entities in Order of Insertion

Is there an internal ID variable or timestamp I can use in a NSSortDescriptor to retrieve Core Data entities in the order they were inserted? I would rather not have to create such properties if there is a cleaner way, though will obviously do so if there are no other alternatives. ...

Is there a sorted_vector class, which supports insert() etc.?

Often, it is more efficient to use a sorted std::vector instead of a std::set. Does anyone know a library class sorted_vector, which basically has a similar interface to std::set, but inserts elements into the sorted vector (so that there are no duplicates), uses binary search to find elements, etc.? I know it's not hard to write, but p...

MVC Paging and Sorting Patterns: How to Page or Sort Re-Using Form Criteria

What is the best ASP.NET MVC pattern for paging data when the data is filtered by form criteria? This question is similar to: http://stackoverflow.com/questions/1425000/preserve-data-in-net-mvc but surely there is a better answer? Currently, when I click the search button this action is called: [AcceptVerbs(HttpVerbs.Post)] pu...

php sorting a seriously multidimensional array...

I'm trying to sort a multidimensional object, and, after looking on php.net and around here, I get that I should write a function that I can then call via usort. I'm having some trouble with the syntax. I haven't ever written something this complicated before, and trying to figure it out feels like a mindbender... I'm working with th...

How to sort filenames correctly like Finder in objective-c

I am binding NStableView with NSMutableArray contiaining filenames and other file details. Simple biniding and sorting with compare: is not properly sorting file names like finder. Please let me know if i need to define custom selector for sorting filenames and how? ...