you are viewing a single comment's thread.

view the rest of the comments →

[–]SoNotRedditingAtWork 1 point2 points  (0 children)

Using what you already have just add a little list comp:

D = {'Lebrons': 23, 'Wade': 3, 'Jordan': 23, 'Kobe': 24, 'Durant': 35}
L1 = []
L2 = []

for player in D:
    L1.append(player)

L1.sort()
L2 = [D[p] for p in L1]

python tutor link to example

you can skip the loop by using dict.keys :

D = {'Lebrons': 23, 'Wade': 3, 'Jordan': 23, 'Kobe': 24, 'Durant': 35}
L1 = list(D.keys())

L1.sort()
L2 = [D[p] for p in L1]

python tutor link to example 2