Sorting a Dictionary in Python

How to sort a dictionary in Python

Luay Matalka
Towards Data Science
4 min readNov 29, 2020

--

Photo by Markus Spiske on Unsplash

Introduction

We can sort lists, tuples, strings, and other iterable objects in python since they are all ordered objects. Well, as of python 3.7, dictionaries remember the order of items inserted as well. Thus we are also able to sort dictionaries using python’s built-in sorted() function. Just like with other…

--

--

Lead Machine Learning Engineer, specializing in MLOps, with a passion for teaching.