sorting

What type of Sorting algorithm is this?

If this is Bubble sort then what is this? Do you see the placement of Swap()? ...

WPF4 Datagrid doesn't sort on column headers

I am trying to implement my first WPF application using an MVVM design pattern. I created an application that is databinding to an ObservableCollection<>. The application renders fine, but I expect the datagrid to re-sort the rows when I click on the column headers. I've researched posts that said: The data source has to implement IEn...

Can this sort be made more elegant/recursive

I have a table which needs to be sorted by several columns - let's say music which is sorted by genre, then by artist, album and so on. Or you can sort by artist/album/track. This is what I came up with in jquery: function tableSort (by) { var mylist = $('#...

How to sort this NSMutableArray?

I made a class called Person. It looks like this Person ------- Name Points Then I created an NSMutableArray called team. It contains several of these person objects. I create several teams. Then I created another NSMutableArray called allTeams. It holds all the team arrays. I want to sort the allTeams array by the total number of p...

How to keep an array sorted

I'm refactoring a project that involves passing around a lot of arrays. Currently, each method that returns an array sorts it right before returning it. This isn't ideal for a couple reasons -- there's lots of duplicated code, it's inefficient to sort an array two or three times, and it's too easy to write a new function but to forget ...

Adapting a sort procedure to accept and sort binary files

I need to adapt a sort method in Java that currently takes text files for my job. I need to change the comparison of the sort, but what is the best way? EDIT: I'm actually trying to edit the implementation of TeraSort to sort binary files, if that is at all helpful. ...

How to change this code so the NSMutableArray is sorted?

I made a custom class. This is the h file @interface Player : NSObject { NSString *name; NSNumber *points; } @property (nonatomic, retain) NSString *name; @property (nonatomic, retain) NSNumber *points; -(id) initWithName:(NSString *)n andPoints:(int)p; @end This is the m file #import "Player.h" @implementation Player @sy...

How do you order by a search phrase found in the beginning of a word and only afterwards the middle using SQL.

Let's say I have table [users] with the field [Name] and I've written a query in my application to search by name. The names in the database are: Lala Ally My SQL query is: SELECT * FROM users WHERE [Name] LIKE '%al%' where 'al' is my search term. How would I sort the results by search term found in the beginning i.e. '%al' and o...

Sorting an array with uksort()

Hello! I have an array like this one: $a = array("MA1" => 0, "MA10" => 1, "MA20" => 2, "MA5" => 3, "SM10" => 4, "SM8" => 5, "SM20" => 6, "SN33" => 7); I want to sort it, that I will have the following order: $a = array("MA1" => 0, "MA5" => 3, "MA10" => 1, "MA20" => 2, "SM8" => 5, "SM10" => 4, "SM20" => 6, "SN33" => 7); So I need a...

Numpy sorting help

In Numpy, how do I create an array of indices which can be used return the values of the source array in sorted order? eg: Source: [[4 2 6 7] [1 4 8 9] [3 1 0 3]] Indices: [10 4 9 1 8 11 0 5 2 3 6 7] ...

How can I parse a csv file and fit it to an existing table in C#?

Okay, so right now I have a parseCSV function that returns a table to me in 2D format like so: List<string[]> data = parseCSVFle(file); Now, I'd like the rows in 'data' to be arranged in a particular order. This order is determined by the first column in temp (i.e. first element of the string array). The order is maintained in a strin...

Does a vector sort invalidate iterators?

std::vector<string> names; std::vector<string>::iterator start = names.begin(); std::vector<string>::iterator end = names.end(); sort (start,end); //are my start and end valid at this point? //or they do not point to front and tail resp? ...

Linq join on parameterized distinct key CASE INSENSITIVE

To revisit a previous question with a further stipulation... Anyone know how to do the following, IGNORING CASE? Dim Matches = From mRows In LinqMasterTable Join sRows In LinqSecondTable _ On mRows(ThePrimaryKey) Equals sRows(TheForignKey) _ Order By mRows(ThePrimaryKey) _ Select mRows, sRows For details ab...

Javascript: sort multidimensional array

After creating a multi-dim array like this, how do I sort it? Assuming 'markers' is already defined: var location = []; for (var i = 0; i < markers.length; i++) { location[i] = {}; location[i]["distance"] = "5"; location[i]["name"] = "foo"; location[i]["detail"] = "something"; } For the above example, I need to sort it by 'di...

PHP uksort() for several arrays

I would like to have a unique sort function for several associative arrays. The best candidate among the various PHP sort functions would be uksort(), (usort() would be ideal, but it changes the array keys to become the numerical index(!)). For instance (using a simpler array) function sorting_by_length_desc ($a, $b) { return...

How to get rightmost 10 places of a string in oracle

Hi, i am trying to fetch an id from an oracle table. Its something like "TN0001234567890345". What i want is to sort the values according to the right most 10 positions. I am using oracle 11g. Is there any funcrion to cut the rightmost 10 places in oracle ? thanks in advance tismon ...

Sorting results by 'most relevent' - MYSQL & PHP

I've never really considered this question before and wondered if anyone has any advice or input on best practices for achieving 'relevent results'. In my case I'm running a search query that includes full text searching across 5 fields, a geographic radial lookup and a number of basic comparisons. I can prioritise the fields I'm most ...

bubblesort from highest to lowest number in java

I'm looking for a bubblesort code in java that is opposite of the usual thing that I'm seeing when I search the internet. I don't really understand the code below, all I know is that it sorts a bunch of numbers from lowest to highest. Is the code below modifiable so that instead of outputting the numbers from lowest to highest. It outpu...

How do you sort CJK (Asian) characters in Perl, or with any other programming language?

How do you sort Chinese, Japanese and Korean (CJK) characters in Perl? As far as I can tell, sorting CJK characters by stroke count, then by radical, seems to be the way these languages are sorted. There are also some methods that sort by sounds, but this seems less common. I've tried using: perl -e 'print join(" ", sort qw(工 然 一 人 三 ...

How can I use SYNCSORT to format a Packed Decimal field with a specifc sign value?

I want to use SYNCSORT to force all Packed Decimal fields to a negative sign value. The critical requirement is the 2nd nibble must be Hex 'D'. I have a method that works but it seems much too complex. In keeping with the KISS principle, I'm hoping someone has a better method. Perhaps using a bit mask on the last 4 bits? Here is the ...