Reversing sorted dictionary in Python 3 -


i'm sorting dictionary key, i'd reverse order. i'm not getting joy few of examples have seen around web.

here sort

tempdict = collections.ordereddict(sorted(tempdict.items())) 

now i'm trying:

reverse = collections.ordereddict(tempdict.items()[::-1]) reverse = collections.ordereddict(map(reversed, tempdict.items())) 

but these not working. smartest , elegant way of sorting dictionary. yes know, dictionaries not used sorting, works us. thanks.

to sort in reverse order:

collections.ordereddict(sorted(tempdict.items(), reverse=true)) 

to reverse existing dict:

collections.ordereddict(reversed(list(tempdict.items()))) 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -