Dictionaries autosorting

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • micmast
    New Member
    • Mar 2008
    • 144

    Dictionaries autosorting

    hey,

    it is possible to make sure that a given dictionary stays the same way?
    for example
    [code=python]
    options = { 'Something':'va lue','abc':'val ue' }
    [/code]

    this should stay the same and not switch like this:
    [code=python]
    >>> options = { 'Something':'va lue','abc':'val ue' }
    >>> print options
    {'abc': 'value', 'Something': 'value'}
    >>>

    [/code]
  • jlm699
    Contributor
    • Jul 2007
    • 314

    #2
    If you use pythonutils you can implement an OrderedDict(), which I've used many times in my scripts. It works exactly like a dictionary, except you initialize it like [code=python]od = OrderedDict()[/code]

    Comment

    Working...