sort (3,930)


c# How do you sort a dictionary by value?

c# How do you sort a dictionary by value?

I often have to sort a dictionary, consisting of keys & values, by value. For example, I have a hash of words and respective frequencies, that I want to order by frequency. There is a SortedList which…


algorithm Efficiently get sorted sums of a sorted list

You have an ascending list of numbers, what is the most efficient algorithm you can think of to get the ascending list of sums of every two numbers in that list. Duplicates in the resulting list are…


How do I remove duplicate items from an array in Perl?

I have an array in Perl: my @my_array=("one","two","three","two","three"); How do I remove the duplicates from the array?…


algorithm Merge Sort a Linked List

I was recently brushing up on some fundamentals and found merge sorting a linked list to be a pretty good challenge. If you have a good implementation then show it off here.…


c++ How does one rank an array(sort) by value?*With a twist*

I would like to sort an array in ascending order using C/C++. The outcome is an array containing element indexes. Each index is corespondent to the element location in the sorted array. Example Input…


Sorting an IList in C#

So I came across an interesting problem today. We have a WCF web service that returns an IList. Not really a big deal until I wanted to sort it. Turns out the IList interface doesn't have a sort metho…


javascript Dynamic Alphabetical Navigation

I'm using ColdFusion to return a result set from a SQL database and turn it into a list. I need some way to generate an alphabetical navigation bar for that list. I have ColdFusion and the jQuery l…


java shortcut for creating a Map from a List in groovy?

I'd like some sorthand for this: Map rowToMap(row){def rowMap=[:]; row.columns.each{ rowMap[it.name]=it.val}return rowMap;}given the way the GDK stuff is, I'd expect to be able…



sorting How do I write a sort worse than O(n!)

I wrote an O(n!) sort for my amusement that can't be trivially optimized to run faster without replacing it entirely.[And no, I didn't just randomize the items until they were sorted]. How might…


Comparing Arrays of Objects in JavaScript

I want to compare 2 arrays of objects in JavaScript code. The objects have 8 total properties, but each object will not have a value for each, and the arrays are never going to be any larger than 8 i…




array list order descending value java how example python multiple