dictionary class : SortByValue(bool) method
Description
Gets a new dictionary which the caller dictionary is sorted by value.
Syntax
dictionaryInstance.SortByValue(bool order)
Arguments
Class | Name | Description |
bool | order | Sort order. |
Return value
Class | Description |
some dictionary | A new dictionary that is sorted. |
Sample code
dictionary{int} orgDic = new dictionary{int}();
orgDic.Add("item1", 10);
orgDic.Add("item2", 8);
orgDic.Add("item3", 9);
dictionary{int} ascDic = orgDic.SortByValue(true);
// order of the ascDic is "item2"/8, "item3"/9, "item1"/10.
dictionary{int} descDic = orgDic.SortByValue(false);
// order of the descDic is "item1"/10, "item3"/9, "item2"/8.
Notes
This method is added in Ver 1.1.0.0.
If the argument is true, the returned dictionary is sorted in ascending order.
If the argument is false, the returned dictionary is sorted in descending order.
Returns a new dictionary that is sorted by value. The order of the caller dictionary does not change.
The returned dictionary is a shallow copy of the caller dictionary. That is, the caller and the returned dictionary refer to the same element.
It will throw an exception (RtypeException) if you call this method on dictionarys other than dictionary{int}, dictionary{long}, dictionary{real}, dictionary{bool}, or dictionary{string}.
Links for reference
None