asp.net mvc dictionary sort
return new M开发者_StackOverflowultiSelectList(dic, "Key", "Value", sel);
How can I sort by value in the dictionary value above? The dictionary is filled by database values.
You could sort the "database values" before adding them to the dictionary, but that would not be entirely reliable.
Use LINQ - type
return
new MultiSelectList
(
dic.OrderBy(x => x.Value),
"Key",
"Value",
sel
)
;
精彩评论