Changes between Version 4 and Version 5 of SortedDict


Ignore:
Timestamp:
Jan 26, 2009, 10:53:52 PM (16 years ago)
Author:
kiwi
Comment:

Example how to correctly create new SortedDict.

Legend:

Unmodified
Added
Removed
Modified
  • SortedDict

    v4 v5  
    1212`value_for_index(index)`[[br]]
    1313Returns the value of the item at the given zero-based index.
     14
     15== Creating new SortedDict ==
     16
     17If you create new SortedDict using basic Python dict, SortedDict will not preserve key order. The reason is that SortedDict will receive (basic Python) unordered dictionary and therefore doesn't know about key order.
     18
     19This does NOT work.
     20{{{
     21d = SortedDict({
     22        'b': 1,
     23        'a': 2,
     24        'c': 3
     25})
     26}}}
     27
     28This works. SortedDict got keys in right order.
     29{{{
     30d2 = SortedDict()
     31d2['b'] = 1
     32d2['a'] = 2
     33d2['c'] = 3
     34}}}
Back to Top