sorting

custom string sorter

I want to sort a collection by one of the properties which is a string, but i dont want to sort alphabetically. Here is my code IEnumerable<Item> items = Repository.Query<Item>().OrderBy(r=> r.Status) Status is a string but i want to sort in a particular order (not alphabetically) how do i inject a custom sorter in the above syntax...

Does STL and vector provide sort option?

Hi, Does STL and Vector provide the default sorting option?. ...

Are there practical limits to the number of open files in Java?

Hi, I've built some file sorting functionality into a java app, and it's designed to sort files larger than 20GB. The general approach is to read the file in chunks, sort each chunk in memory, then write it to its own temporary sorted file. On the second pass, I open all chunk files simultaneously and weave them together into a final so...

MySQL: applying a random sort on multiple columns

Hello. In order to have a well scrambled table (for a psychological experiment), I'd like to sort each column of my array by RAND(). Althrough this code works: SELECT Sort.Variable1, Sort.Variable2 FROM Sort ORDER BY Variable1, Variable2 ASC LIMIT 0 , 30 replacing "ASC" by "RAND()" make the query fail. Can someone give me an advice (e...

Interesting sorting problem

There are ones, zeroes and ‘U’s in a particular order. (E.g. “1001UU0011”) The number of ones and zeroes are the same, and there’s always two ‘U’s next to each other. You can swap the pair of ‘U’s with any pair of adjacent digits. Here’s a sample move: __ / \ 1100UU0011 --> 11001100UU The task is to put all the zeroes befo...

How to monitor/show progress during a C++ sort

I'm planning to write an interactive C++ geometry processing plug-in that will frequently sort large amounts of data. Although preliminary indications are that the sort will take only a second or two, I'd prefer to show progress during that time - i.e I'd like to update a progress indicator a few times per second. This would be prefera...

VB.NET Strange sort behavior?

Hi, I've got a class with the following overload: Public Overloads Function CompareTo(ByVal obj As Object) As Integer Implements IComparable.CompareTo ' I want a logmile, darn it! If Not TypeOf obj Is Logmile Then Throw New ArgumentException If Me("beg_logmile") > obj("beg_logmile") OrElse Me("end_logmile") > obj("end_logm...

Should I index my sort fields in MySQL

I have a field called 'sort_order' and it's bigint, i use it in my mysql queries for sorting. Is it wise I put an index on it? ...

Fast Hamming distance scoring

There is a database with N fixed length strings. There is a query string of the same length. The problem is to fetch first k strings from the database that have the smallest Hamming distance to q. N is small (about 400), strings are long, fixed in length. Database doesn't change, so we can pre-compute indexes. Queries vary strongly, cac...

How To Sort Tab Format File Based on Length of Column K

I have a space delimited tabular file that looks like this: >NODE 28 length 23 cov 11.043478 ACATCCCGTTACGGTGAGCCGAAAGACCTTATGTATTTTGTGG >NODE 32 length 21 cov 13.857142 ACAGATGTCATGAAGAGGGCATAGGCGTTATCCTTGACTGG >NODE 33 length 28 cov 14.035714 TAGGCGTTATCCTTGACTGGGTTCCTGCCCACTTCCCGAAGGACGCAC How can I use Unix sort to sort it by leng...

How do you handle the SelectedIndex of a sortable ListView?

I have an asp.net ListView that is sortable. I have a button with a "select" command name. When I click on the button the appropriate row gets selected. If I then click on a sort header the ListView will sort, but the selected index will stay the same. In other words if I click the 2nd row then sort the 2nd row is still selected. Is...

Sorting an array of folder names like Windows Explorer (Numerically and Alphabetically) - VB.NET

I'm killing myself and dehydrating trying to get this array to sort. I have an array containing directories generated by; Dim Folders() As String = Directory.GetDirectories(RootPath) I need them to be sorted so they appear like in windows explorer in win7 / vista. -- numerically and alphabetically by folder names. The folder names co...

jQuery tablesorter textExtractionCustom problem

Hello, I have a table setup like this: <table id="product_table"> <thead> <tr> <th>Name</th> <th>Bandwidth</th> <th>Price</th> </tr> </thead> <tbody> <tr> <td>Name #1 (works fine)</td> <td>Technology<br /><span>3000</span> / 600</td> ...

The Travel Tickets Problem

You are given a stack of travel tickets for various transportations that will take you from a point A to point B via several stops on the way. All of the tickets are out of order and you don't know where your journey starts, nor where it ends. Sort the tickets in the right order to complete your journey. tickets = [ {from: "Barcelo...

how do you sort puncation with jquery tablesorter?

I have a column that contains address "line 2" type values. this column can contain values like #431, UNIT 203, and APT. C and of course it can contain blank (or empty string) values also. i need an answer to two questions: How would you expect a mixed values like this to be sorted (i.e. blank or pound signs on top when ascending)? ...

Sorting a multi-dimensional array by the sequence of another array

Consider the following array: $main_array = array(); $main_array[0] = array('location'=> array('France', 'Germany'), 'random_number'=> array('6520')); $main_array[1] = array('location'=> array('Italy', 'Switzerland'), 'random_number'=> array('3245')); $main_array[2] = array('location'=> array('Portugal', 'Spain'), 'random_number'=> arra...

linux bash 'sort' in dictionary order - problem with zeros

Hi, I'm seeing something strange with 'sort' in RedHat Enterprise Linux 5 x86_64 and in Ubuntu 9.1. I'm using bash. First here's what I think is right to expect from sort using dictionary order: [stauffer@unix-m sortTrouble]$ cat st1 1230 123 100 11 10 1 123 1230 100 [stauffer@unix-m sortTrouble]$ sort st1 1 10 100 100 11 123 123 1...

Sort JavaScript String Array containing numbers

I have an array in javascript that contains the following: ["Value 1", "Value 5". "Value 10", "Value 11"]; How would I go about sort this array so that it does not appear as follows: ["Value 1", "Value 10". "Value 11", "Value 5"]; But as: ["Value 1", "Value 5". "Value 10", "Value 11"]; Any help would be great. ...

List Sorting puzzle

Assuming I have final Iterable<String> unsorted = asList("FOO", "BAR", "PREFA", "ZOO", "PREFZ", "PREFOO"); What can I do to transform this unsorted list into this: [PREFZ, PREFA, BAR, FOO, PREFOO, ZOO] (a list which begin with known values that must appears first (here "PREFA" and "PREFZ") and the rest is alphabetically sorted) ...

How to sort a list of objects by a specific member?

Say I have a list of Person objects: class person { int id; string FirstName; string LastName; } How would I sort this list by the LastName member? List<Person> myPeople = GetMyPeople(); myPeople.Sort(/* what goes here? */); ...