How do I sort a dictionary by key

0 votes

How do I sort a dictionary by its keys?

Example input:

{2:3, 1:89, 4:5, 3:0}

Desired output:

{1:89, 2:3, 3:0, 4:5}
Jan 5, 2023 in Python by erzan
• 630 points

edited 4 days ago 8 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP