Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature currently requires accessing the site using the built-in Safari browser.
def sortedDictValues1(adict):
items = adict.items()
items.sort()
return [value for key, value in items]
Ein Dictionary ist immer nach den Keys sortiert. Das ist ja gerade der Sinn eines "Wörterbuches".hallo,
ich erhalte dann aber eine Liste mit den values, ich möchte aber wieder mein dictionary haben
a_dict = { "a"=1, "b"=5, "c"=3}
another_dict = dict((v, k) for (k, v) in a_dict.items())
>>> d = { "a":1, "b":5, "c":3}
>>> d
{'a': 1, 'c': 3, 'b': 5}
>>> for item in sorted(d.items(),key=lambda x: x[1]):
... print item
...
('a', 1)
('c', 3)
('b', 5)
>>> dict( pupsgesicht=22, hallowelt=12, ichbinmuede = 243 )
{'ichbinmuede': 243, 'hallowelt': 12, 'pupsgesicht': 22}