0

My output: enter image description here

What it's supposed to look like: enter image description here

My code: enter image description here

My output:

Jersey number: 84, Rating: 7
Jersey number: 4, Rating: 5
Jersey number: 66, Rating: 9

Asking for:

Jersey number: 4, Rating: 5
Jersey number: 66, Rating: 9
Jersey number: 84, Rating: 7

I am not sure how to get the jersey numbers in the desired order, I've tried a variety of ways and I'm still unsure. The specific order is where it's getting me. Any ideas? Thank you for reading!

blhsing
  • 91,368
  • 6
  • 71
  • 106
  • 2
    Please include the code from your question as text that can be copied instead of linking to images - helps those that want to try and run it actually run it – n8sty Oct 19 '18 at 03:33
  • Also [How do I print a sorted Dictionary in Python 3.4.3](https://stackoverflow.com/questions/35609991/how-do-i-print-a-sorted-dictionary-in-python-3-4-3) – Ilja Everilä Oct 19 '18 at 03:51
  • @Adrien Arbuckle Please be specific with your query and explain all the variables you have used in the code. What is rating_above and team whether it is a dictionary or an array of dict? – nilansh bansal Oct 19 '18 at 04:01

1 Answers1

0

Since you want to sort the dict by the keys, which happens to be the first item of the item tuples, you can simply sort the dict items by the tuple order instead:

for jersey, rating in sorted(team.items()):
blhsing
  • 91,368
  • 6
  • 71
  • 106