Quantcast
Channel: Planet Python
Viewing all articles
Browse latest Browse all 24356

Real Python: Sorting Dictionaries in Python: Keys, Values, and More

$
0
0

You’ve got a dictionary, but you’d like to sort the key-value pairs. Perhaps you’ve tried passing a dictionary to the sorted()function but didn’t receive the results you expected. In this video course, you’ll go over everything you need to know to sort dictionaries in Python.

In this video course, you’ll:

  • Review how to use the sorted() function
  • Learn how to get dictionary views to iterate over
  • Understand how dictionaries are cast to lists during sorting
  • Learn how to specify a sort key to sort a dictionary by value, key, or nested attribute
  • Review dictionary comprehensions and the dict()constructor to rebuild your dictionaries
  • Consider alternative data structures for your key-value data

[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]


Viewing all articles
Browse latest Browse all 24356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>