Works for me. What version of Julia are you using? Note that if you have the integer before the string in each tuple, you can just sort the array.
At one point while I was developing the OrderedDict class in DataStructures.jl, I made it possible to sort it (and sorting regular dictionaries returned an OrderedDict. It should be pretty easy to add that functionality back. You would need to load the DataStructures.jl package, of course.
Right, but for getting all the pairs in order, I don't think that ordering them during insertion is helpful – it would be better to just sort them all at once afterwards.
d = Dict{String,Int}()# count the wordsa = [ (c,w) for (w,c) in d ]sort!(a)
On Sunday, June 15, 2014 5:11:31 PM UTC-4, Kevin Squire wrote:At one point while I was developing the OrderedDict class in DataStructures.jl, I made it possible to sort it (and sorting regular dictionaries returned an OrderedDict. It should be pretty easy to add that functionality back. You would need to load the DataStructures.jl package, of course.That makes a lot of sense to me. Is this something that works now, or are you suggesting this as a possible future functionality?
Also, I assume the time it takes to sort an OrderedDict would be on the same order as sorting a Array of Tuple pairs. Is that right?