Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sorting a Dictionary by Value

I have a dictionary in the form of:

{ "honda" : 4, "toyota": 7, "ford" : 3, "chevy": 10 }

I want to sort it by the second column aka (the value) descending.

Desired output:

"chevy", 10

"toyota", 7

"honda", 4

"ford", 3

like image 264
s15199d Avatar asked Apr 19 '10 22:04

s15199d


1 Answers

Thanks to caryden from: How do you sort a dictionary by value?

Dim sortedDict = (From entry In dict Order By entry.Value Descending Select entry)

The issues reported above were due to improper looping.

like image 132
s15199d Avatar answered Oct 01 '22 13:10

s15199d