sorting

How can I sort by multiple conditions with different orders?

I'd really like to handle this without monkey-patching but I haven't been able to find another option yet. I have an array (in Ruby) that I need to sort by multiple conditions. I know how to use the sort method and I've used the trick on sorting using an array of options to sort by multiple conditions. However, in this case I need the...

How to set the header sort glyph in a .NET ListView?

How do i set the column which has the header sort glyph, and its direction, in a .NET 2.0 WinForms ListView. Bump The listview is .net is not a managed control, it is a very thin wrapper around the Win32 ListView common control. It's not even a very good wrapper - it doesn't expose all the features of the real listview. The Win32 list...

Alphanumeric Sorting

What is the best/fastest way to sort Alphanumeric fields? ...

is Microsoft sort.exe able to sort unicode UTF-16 (LE) files?

Is Microsoft sort.exe 5.1.2600.0 (xpclient.010817-1148) able to sort UTF-16 (LE) files? ...

Sort with one option forced to top of list

I have a PHP application that displays a list of options to a user. The list is generated from a simple query against SQL 2000. What I would like to do is have a specific option at the top of the list, and then have the remaining options sorted alphabetically. For example, here's the options if sorted alphabetically: Calgary Edmonton ...

php $_GET sort problem

here is the input i am getting from my flash file process.php?Q2=898&Aa=Grade1&Tim=0%3A0%3A12&Q1=908&Bb=lkj&Q4=jhj&Q3=08&Cc=North%20America&Q0=1 and in php i use this code foreach ($_GET as $field => $label) { $datarray[]=$_GET[$field]; echo "$field :"; echo $_GET[$field];; echo "<br>"; i get this out put Q2 :898 Aa :Grade1 ...

How do I sort a multidimensional array in php

I have CSV data loaded into a multidimensional array. In this way each "row" is a record and each "column" contains the same type of data. I am using the function below to load my CSV file. function f_parse_csv($file, $longest, $delimiter) { $mdarray = array(); $file = fopen($file, "r"); while ($line = fgetcsv($file, $longe...

I need to join two lists, sort them and remove duplicates. Is there a better way to do this?

I have two unsorted lists and I need to produce another list which is sorted and where all the elements are unique. The elements can occur multiple times in both lists and they are originally unsorted. My function looks like this: (defun merge-lists (list-a list-b sort-fn) "Merges two lists of (x, y) coordinates sorting them and r...

Sort on a string that may contain a number

I need to write a Java Comparator class that compares Strings, however with one twist. If the two strings it is comparing are the same at the beginning and end of the string are the same, and the middle part that differs is an integer, then compare based on the numeric values of those integers. For example, I want the following strings...

sorting hashes/arrays in awk

Is there an easy way to do any of the following things in awk? Sorting array/hash by it's data Sorting a hash by it's string key ...

Sorting matched arrays in Java

Let's say that I have two arrays (in Java), int[] numbers; and int[] colors; Each ith element of numbers corresponds to its ith element in colors. Ex, numbers = {4,2,1} colors = {0x11, 0x24, 0x01}; Means that number 4 is color 0x11, number 2 is 0x24, etc. I want to sort the numbers array, but then still have it so each element ma...

Stable, efficient sort?

I'm trying to create an unusual associative array implementation that is very space-efficient, and I need a sorting algorithm that meets all of the following: Stable (Does not change the relative ordering of elements with equal keys.) In-place or almost in-place (O(log n) stack is fine, but no O(n) space usage or heap allocations. O(n ...

What is the fastest way (in theory at least) to sort a heap?

A heap is a list where the following applies: l[i] <= l[2*i] && l[i] <= [2*i+1] for 0 <= i < len(list) I'm looking for in-place sorting. ...

Table Sorting using CodeIgniter

Hi I've been developing a site over the past few weeks using CodeIgniter as the framework. It's a great framework, however I've been puzzling over the best way to accomplish something which in a lot of other frameworks / languages is relatively simple: sortable tables. CodeIgniter switches off query strings by default, because your URL...

How to sort an array of UTF-8 strings?

I currentyl have no clue on how to sort an array which contains UTF-8 encoded strings in PHP. The array comes from a LDAP server so sorting via a database (would be no problem) is no solution. The following does not work on my windows development machine (although I'd think that this should be at least a possible solution): $array=arra...

What would be the simplest way to alpha sort an array of chars in C?

I'm looking for a simple, easy to understand algorithm to alphabetically sort an array of characters in C. ...

Sort Object in PHP

What is an elegant way to sort objects in PHP? I would love to accomplish something similar to this. $sortedObjectArary = sort($unsortedObjectArray, $Object->weight); Basically specify the array I want to sort as well as the field I want to sort on. I looked into multidimensional array sorting and there might be something useful there...

Sorting strings is much harder than you thought!

Sorting a list of strings in a way that makes sense to a human is a very complex task. It's not just about comparing ASCII values. Usually, the case doesn't matter. You probably want "File 2" to be sorted before "File 11". In German, 'Ä' often comes at the beginning of the alphabet, whereas in Swedish it's towards the end. And what about...

Algorithm for merging large files

I have several log files of events (one event per line). The logs can possibly overlap. The logs are generated on separate client machines from possibly multiple time zones (but I assume I know the time zone). Each event has a timestamp that was normalized into a common time (by instantianting each log parsers calendar instance with the ...

How do I sort a list of integers using only one additional integer variable?

How to sort list of values using only one variable? EDIT: according to @Igor's comment, I retitled the question. ...