Asked • 04/27/19

How can I sort a dictionary by key?

What would be a nice way to go from `{2:3, 1:89, 4:5, 3:0}` to `{1:89, 2:3, 3:0, 4:5}`? I checked some posts but they all use the "sorted" operator that returns tuples.

1 Expert Answer

By:

Daniel U. answered • 04/30/19

Tutor
5 (44)

Professional Software Developer and PhD Here To Help

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.