sorting

Number of matches for an ELO Rating system

I'm creating a system that will allow people to rate images. My idea is to use an ELO Rating system (http://en.wikipedia.org/wiki/Elo_rating_system) for each image and then use crowdsourcing to have people say if an individual image is better than another i.e Is A better than B This will be used to updated the ELO rating of A and B,...

Why does "-less" sort after "hello" instead of before it?

I'm seeing some very strange sorting behaviour using CaseInsensitiveComparer.DefaultInvariant. Words that start with a leading hyphen "-" end up sorted as if the hyphen wasn't there rather than being sorted in front of actual letters which is what happens with other punctuation. So given { "hello", ".net", "-less"} I end up with {".net"...

Sorting a list alphabetically with a modulus

I don't have any trouble grabbing a list of elements and sorting them alphabetically, but I'm having difficulty understanding how to do it with a modulus. ### UPDATE ### Here's the code working 'my way', however, I like the re-usability of the answer provided below more, so have accepted that answer. <script type="text/javascript"> $(...

Python, Sorting

Hello, i have a list. name|num|num|num|num name|num|num|num|num name|num|num|num|num How i can sort this list on need me field (2,3,4,5) ? Sorry for my enlish. Update Input: str|10|20 str|1|30 Sort by first field (1,10): str|1|30 str|10|20 Sort by second field(20,30): str|10|20 str|1|30 ...

How to sort a Listview in a DataTemplate in XAML only?

I have a window with a TabControl that i've bind to a list of objec, I'll called MyItem : <TabControl Name="MyTabPNL" Background="Gainsboro" ItemsSource="{Binding MyItemList, ElementName=WatcherWindow}" ContentTemplate="{StaticResource tabItemTemplate}"> </TabControl> This MyItem class has an ObservableCollect...

C# radix sort for strings of arbitrary lengths

I need to sort a huge list of text strings of arbitrary length. I suppose radix sort is the best option here. List is really huge, so padding strings to the same length is completely impossible. Is there any ready-made implementation for this task, preferably in C#? ...

A List in alphabetical order going down not across?

I have a giant list that comes out of my database in alphabetical order. It is placed in a Div with a set width. I have each floated left and the are all next to each going from left to right and its great. BUT my client wants the order to go down not across. So it is like this: apple angry antler bone beard broken She wants: ap...

Sorting list that has tuple as an element with Python

I have a list as follows. [(5,), (2,), (4,), (1,), (3,), (6,), (7,), (8,)] How can I sort the list to get [1,2,3,4,5,6,7,8] or [8,7,6,5,4,3,2,1] ? ...

How can you sort an array of GPS coordinates to draw a non-overlapping bounding box?

I have a collection of GPS coordinates (Lat/log) in an array that I want to use to create a polygon in google maps. If i use the unsorted array, the polygon lines are drawn in the order of the array index. I am wondering if there is a way to sort the array such that when i draw the polygon, the borders do not overlap. Any insight will ...

Are you able to use a custom Postgres comparison function for ORDER BY clauses?

In Python, I can write a sort comparison function which returns an item in the set {-1, 0, 1} and pass it to a sort function like so: sorted(["some","data","with","a","nonconventional","sort"], custom_function) This code will sort the sequence according to the collation order I define in the function. Can I do the equivalent in Postg...

How to sort Magento product list by product rate?

Hi, I would like to sort product list by product rate. Is it possible? I googled about it, but I only found how to sort by newest, name, category. ...

Python trim last and sort list

I have list MC below: MC = [('GGP', '4.653B'), ('JPM', '157.7B'), ('AIG', '24.316B'), ('RX', 'N/A'), ('PFE', '136.6B'), ('GGP', '4.653B'), ('MNKD', '672.3M'), ('ECLP', 'N/A'), ('WYE', 'N/A')] def fn(number): divisors = {'B': 1, 'M': 1000} if number[-1] in divisors: return ((float(number[:-1]) / divisors[number[-1]]) ...

How to sort find result such that paths beginning with one of a set of patterns are sorted last.

I have a find command that I would like to sort such that entries for certain directories are sorted last. The reason is that this list is to be passed to etags to create a tags table and I would like certain third-party tool directories to be after all the code I actively edit. Can someone suggest a good easy way in to sort the list a...

php sort array issue

i want to sort an array by alphabet when i use asort() its sorting , but the results that i get is first of all , the names in upper-case, and after that all the names with lower-case like : Avi Beni .. .. avi beni if i want like : Avi avi Beni beni .. .. how can i do it ? ...

How to sort an array of ints using a custom comparator?

I need to sort an array of ints using a custom comparator, but Java's library doesn't provide a sort function for ints with comparators (comparators can be used only with objects). Is there any easy way to do this? ...

SQL sorting , paging, filtering best practices in ASP.NET

I am wondering how Google does it. I have a lot of slow queries when it comes to page count and total number of results. Google returns a count value of 250,000,00 in a fraction of a second. I am dealing with grid views. I have built a custom pager for a gridview that requires an SQL query to return a page count based on the filters s...

How do I sort a PHP array by an element nested inside?

I have an array like the following: Array ( [0] => Array ( 'name' => "Friday" 'weight' => 6 ) [1] => Array ( 'name' => "Monday" 'weight' => 2 ) ) I would like to grab the last values in that array (the 'weight'), and use that to sort the main arra...

How to sort an ArrayList using multiple sorting criteria?

I have an array list that contains Quote objects. I want to be able to sort alphabetically by name, by change, and by percent change. How can I sort my arraylist? package org.stocktwits.model; import java.io.Serializable; import java.text.DecimalFormat; public class Quote implements Serializable { private static final lon...

Vector sorting: swap overload

I would like to overload swap function for std::vector of primitive types / objects. The reason is a slow sorting of vectors containing big objects using std::sort. Here is the simple but not working example. #include <vector> #include <algorithm> class Point { private: double x, y; public: Point(double xx, double yy) : x(xx), y...

Help comparing float member variables using Comparators

I am able to compare Strings fine, but would like to know how I can rank floating point numbers? getChange() returns a String. I want to be able to sort descending. How can I do this? UPDATE: package org.stocktwits.helper; import java.util.Comparator; import org.stocktwits.model.Quote; public class ChangeComparator implements Compa...