Smalltalk
›
Squeak
›
Squeak - Dev
Search
everywhere
only in this topic
Advanced Search
sorting a dictionary by value
‹
Previous Topic
Next Topic
›
Classic
List
Threaded
♦
♦
Locked
2 messages
Joseph Alotta
Reply
|
Threaded
Open this post in threaded view
♦
♦
|
sorting a dictionary by value
Greetings,
There were some answers for sorting a dictionary by key, but nothing on sorting by value.
dict associations asSortedCollection =>
a SortedCollection('ABB'->1625.68 'ABT'->41514.16 'ABV'->11393.37 'ACCO'->954.77 'ACMP'->4626.56 'ADC'->1151.66 'ADI'->17375.44 'ADP'->17762.98 'ADUS'->1219.63 'AEE'->30939.24 'AEO'->8560.08 'AEP'->94319.6 'AHGP'->2895.92 'ALE'->6510.47 'ALG'->4345.05
But I want to sort by the value?
Thank you for your help,
Joe.
Sungjin Chun
Reply
|
Threaded
Open this post in threaded view
♦
♦
|
Re: sorting a dictionary by value
How about
dict associations asArray sort: [ :a :b | a value < b value ]
?
On Fri, Oct 5, 2012 at 1:38 PM, Joseph J Alotta <
[hidden email]
> wrote:
> asSortedCollection
Free forum by Nabble
Edit this page