sorting

MySQL Count and sort rows

What is the best way to count and sort a column of data in mysql and output the results as a html list? Example Data: **Type** Train Car Car Car Bus Bus Output should be sorted with largest count item first: - car(3) - bus(2) - train (1) Also, is this bad practice to do on large table? ...

How to sort a multidimensional array by a certain key?

This should be really simple, but what is the way to go on this. I want to sort an multidimensional array by a key, like this: Array ( [0] => Array ( [iid] => 1 [invitee] => 174 [nid] => 324343 [showtime] => 2010-05-09 15:15:00 [location] => 13 [status] => 1 [created] => 2010-...

passing a class method as opposed to a function in std::sort

hi, Within a class, I am trying to sort a vector, by passing a method of the same class. But it gives errors at the time of compilation. Can anyone tell what the problem is? Thank you! it gives the following error: argument of type bool (Sorter::)(D&, D&)' does not matchbool (Sorter::*)(D&, D&)' I have also tried using sortBynumb...

Sort collection of objects in HashMap based on the object's variable

I have a collection of book objects in a HashMap. The book has book_title, book_author, book_year_published, etc. I want to sort them based on the book_title which is a String, in both ascending and descending order, and display them on the screen. I wish someone can help me - I have been doing this for hours and still havent come up w...

sort a list of percentages

I have the following list: l = ['50%','12.5%','6.25%','25%'] Which I would like to sort in the following order: ['6.25%','12.5%','25%','50%'] Using l.sort() yields: ['12.5%','25%','50%','6.25%'] Any cool tricks to sort these lists easily in Python? ...

How can I sort a Flash Actionscript 3 Tilelist based on columns and not rows?

Hi all - I have a Flash Tilelist component (not flex) and have set it up so that 4 rows of 3 tiles each are visible before scrolling. I should note that I'm using a horizontal layout because I need a horizontal scrollbar. I realize using a vertical layout would sort the way I want but gives a vertical scrollbar. The problem I'm encount...

Best way to Sort-n-Concatenate 5 columns

!!! WARNING !!! Dearest SQL expert, please keep reading before to start to scream. this uber-denormalized table structure is obtained after apply some combinatories-sugar upon a nicely normalized set of data : ). I'm avoiding to renormalize this resultset because I want to keep simple the complete process (also this...

ToList().Sort() in Linq query gives compilation error

I am trying to combine two SortedDictionaries, change the result to a List<KeyvaluePair<string,string>> and Sort() the result. The following statement throws an error: var combinedEntries = from p in leftDict.Union(rightDict).ToList().Sort(myComparer) select p; Error: Could not find an implementation of the query pattern for source ty...

WPF 4, ListView and ListCollectionView custom sorting

I'm trying to use a custom sort with a ListView, as described in this blog entry. I'm doing ListCollectionView view = (ListCollectionView)CollectionViewSource.GetDefaultView(TheList.ItemsSource); as recommended there and in several other places, but for some reason I'm getting "Unable to cast object of type 'MS.Internal.Data.Enumerab...

Linear-time algorithms for sorting vertices in polygon contours

I figured out an algorithm that lets me turn my holed polygons into trapezoids in linear time if I have vertex indices sorted from lowest coordinate to highest. I get simple polygons as contours. They have certain order that might be exploited most of the time. So giving these conditions, is there a near-linear-time algorithm on sortin...

Save the sortorder from a datagrid

I whant to save the sortorder and the selectedIndex from my Silverlight datagrid. I use: Application.Current.Resources.Add("CurrentIndex", dg.SelectedIndex); to save the selectedIndex. If my list was sorted when i selected a item the index will not be correct when returning to the datagrid. How do I save the sortorder so the correc...

Sorting CouchDB Views By Value

Hi all, I'm testing out CouchDB to see how it could handle logging some search results. What I'd like to do is produce a view where I can produce the top queries from the results. At the moment I have something like this: Example document portion { "query": "+dangerous +dogs", "hits": "123" } Map function (Not exactly what I n...

Is std::pair<int, std::string> ordering well-defined?

It seems that I can sort an std::vector<std::pair<int, std::string>>, and it will sort based on the int value. Is this a well defined thing to do? Does std::pair have a default ordering based on it's elements? ...

Why doesn't this Perl array sort work?

Why won't the array sort? CODE my @data = ('PJ RER Apts to Share|PROVIDENCE', 'PJ RER Apts to Share|JOHNSTON', 'PJ RER Apts to Share|JOHNSTON', 'PJ RER Apts to Share|JOHNSTON', 'PJ RER Condo|WEST WARWICK', 'PJ RER Condo|WARWICK'); foreach my $line (@data) { $count = @data; chomp($line); @fields = split(/\...

Is there a way to sort by more than one field in Crystal Reports?

I'm using Crystal Report with VB.NET in Visual Studio 2005. I have report that works if I pass in a list of List(Of Stuff). I had been sorting the report by one of the members of Stuff but a need now to sort first by one member, like Stuff.StatusCode and then by another member, like Stuff.ItemNumber. Can I do this just be having more ...

Sort specific items of an array first

I have a ruby array that looks something like this: my_array = ['mushroom', 'beef', 'fish', 'chicken', 'tofu', 'lamb'] I want to sort the array so that 'chicken' and 'beef' are the first two items, then the remaining items are sorted alphabetically. How would I go about doing this? ...

Ajax enabled sorting and paging on grid in ASP.NET 3.5

Is there any good solution for ajax enabled Grid with pageing and sorting which only brings the required data from database? I mean it should only bring the data from the database which is to be displayed on the particular page number of the grid. I looked at this. It looks good. But I just thought if anyone has created something better...

What's the best way to store sort order in SQL?

The guys at the top want sort order to be customizable in our app. So I have a table that effectively defines the data type. What is the best way to store our sort order. If I just created a new column called 'Order' or something, every time I updated the order of one row I imagine I would have to update the order of every row to ensure ...

Sorting in Matlab

Hi, I would like to sort elements in a comma-separated list. The elements in the list are structs and I would like the list to be sorted according to one of the fields in the struct. For example, given the following code: L = {struct('obs', [1 2 3 4], 'n', 4), struct('obs', [6 7 5 3], 'n', 2)}; I would want to have a way to sort L ...

sorting arrays in numpy by column

How can I sort an array in numpy by the nth column? e.g. a = array([[1,2,3],[4,5,6],[0,0,1]]) I'd like to sort by the second column, such that I get back: array([[0,0,1],[1,2,3],[4,5,6]]) thanks. ...