sorting

Sorting an Array of strings with capital and lowercase letters in C

Is there a way to sort an array of strings in alphabetical order where the strings contain both capital and lowercase letters? Because capital letters have a lower ASCII value so functions like strcmp would always show that it is before a lower case letter. For example, lets say we wanted to sort "ABCD", "ZZZZ", "turtle", "JAVA", "wate...

CouchDB: Get result from a view IN a view

Hi there, I want to reuse outputted data from a view in another view. like this reduced and grouped data: {"rows":[ {"key":"cool","value":3}, {"key":"einzigartig","value":1}, {"key":"mega","value":1}, {"key":"nice","value":1}, {"key":"spitze","value":1}, {"key":"super","value":2} ]} ...because I want to interchange key <> value so th...

jqGrid default sort order?

It appears that the jqGrid sortname and sortorder properties do not actually cause your data set to be sorted - they just cause the up/down arrows to be displayed. How can you get your data set to sort on download? The sort works well when you click the column headers but I want a default sort to be applied to our data. Update: Wh...

Best way to sort an array in PHP using a key-function?

usort and uasort use a comparison function which is slow because it must be computed every time a comparison is needed between to elements of an array. Other languages, like Python, let you sort an array using a key function which gets evaluated only once per element in the array. What's the best way to do this in PHP? ...

ASP.NET Datalist Sorting (XMl Source)

I am populating a datalist control with a simple xml source. It displays some Dates in whatever order they are displayed in the xml file. I want them to be sorted before they are displayed in the Datalist. Can this be done? ...

Sorting an Array error ?

Hello, I'm trying to sort an array, from a previous post I was pointed to an answer in this thread, http://stackoverflow.com/questions/1422840/sorting-an-array-of-doubles-or-cllocationdistance-values-on-the-iphone/1422881#1422881 Based of this my code is as follows: NSArray *sortedArray = [listArray sortedArrayUsingFunction:intSort co...

jqGrid - Having text boxes along with sorting

Apparently when editing a row, sorting via column headings is disabled. We want to have a grid where a text box always appears in each row where users can enter data and then hit a submit button. We figured out how to display a text box for each row BUT the problem is that this disables sorting. Any way to do both? ...

Performance of built-in .NET collection sorters

There was a question asked about how to sort a List. There were several methods given from the basic List.Sort() to List.OrderBy(). The most laughable was a roll-your-own-SelectionSort. I promptly voted that down, but it made me think; wouldn't Linq's OrderBy(), applied to a list, do the same thing? myList.OrderBy(x=>x.Property).ToList()...

External Sort Java

Is there a specific reason why Java does not have an in-built external sort algorithm implemented ? ...

Wordpress - custom sort order

hello, can you help me, how can i sort posts by some custom field, in wordpress 3? do i need to create some custom fields, and add new field in db, or...? tnx in adv! ...

Sorting GridView by row number in asp.net C# ?

I have a GridView with a row number (Container.DataItemIndex) column in ASP.NET (1,2,3,4, ...) I added it in GridView by following code : <asp:TemplateField HeaderText="#" SortExpression="#"> <ItemTemplate> <%# Container.DataItemIndex + 1 %> </ItemTemplate> </asp:TemplateField> I wanna sort the ...

Force Specific Record to Top When Performing GROUP BY

I have the following MySQL query and tables from which I am querying: SELECT `Song`.`id`, `Song`.`file_name`, `User`.`first_name`, `Vote`.`value`, Sum(`Vote`.`value`) AS score FROM `songs` AS `Song` LEFT JOIN votes AS `Vote` ON (`Song`.`id`=`Vote`.`song_id`) LEFT JOIN `users` AS `User` ON (`Song`.`user_id` = `User`.`id`) GROUP BY `...

Self Sorting Listbox

Totally stumped by something that seems easy, and has been done to death... Yet still stumped. What I want to do: I've got a WinForms ListBox. Its items are populated with objects, the DisplayMember is set. As the app runs, the data in the listed items might change, including the field behind the DisplayMember. I want the text disp...

Evaluating expression of Facelets components in Richfaces sort

Hello guys, I have some problem evaluating expression in a Facelets component defined in a .taglib.xml SortField2.getExpression() gives me the value "#{sortBy}" instead of evaluating the value. My component (a simple column) is defined as: <ui:composition> <rich:column sortBy="#{sortBy}" width="#{width}" styleClass="#{style...

Fastest way to remove duplicate lines in very large .txt files

What is the best way to remove duplicate lines from large .txt files like 1 GB and more ? Because removing one-after-another duplicates is simple, we can turn this problem to just sorting file. Assume, that we can't load whole data to RAM, because of it's size. I'm just waiting to retreive all records from SQL table with one unique in...

Mistake in calling std::stable_sort ?

struct SimGenRequest { int wakeup_mfm_; double value_; bool operator < ( const SimGenRequest & r2 ) const { return ( wakeup_mfm_ < r2.wakeup_mfm_ ) ; } }; Use : std::stable_sort ( all_requests_.begin ( ), all_requests_.end ( ) ); Works ( compiles ). But struct SimGenRequest { int wakeup_mfm_; doubl...

Slow mergesort implementation, what's wrong?

Hello, I am getting unexpected(?) results from this mergesort implementation. It's extremely slow compared to my three-way quicksort(also written in python). My quicksort finishes with 10000 elements after about 0.005s while mergesort needs 1.6s! Including the source code for both implementations. Mergesort: #Merges two sorted lists...

Dojo EnhancedGrid nested sorting not working

I am trying to create an Enhanced Grid with nested sorting functionality in Dojo but when I go to add the nested sorting functionality via the plugins the grid no longer works (shows up) in the page. My enhanced grid creation code is as follows: dojo.require("dojox.grid.EnhancedGrid"); dojo.require("dojox.grid.enhanced.plugins.NestedSo...

MATLAB error - ??? Attempt to reference field of non-structure array.

I'm writing an insertion sort in MATLAB. I called my function like this: >> A = [5 4 3 2 1] A = 5 4 3 2 1 >> insertion_sort(A) but when I run it I get the error ??? Attempt to reference field of non-structure array. Error in ==> insertion_sort at 6 for j=2:original.length Here's my original c...

PHP - Combine sub-arrays and sort by value?

This is what i've got now: Array ( [0] => Array ( [0] => Array ( [id] => 53 [date] => 18 Sep 2010 10:29 [user] => 52 [post] => ytiuy ) [1] => Array ( [id...