Workout #11: Alphabetizing Names

Sep 24, 2021

Let’s assume you have phone book data in a list of dicts, as follows:

PEOPLE = [{'first':'Reuven', 'last':'Lerner',
'email':'reuven@lerner.co.il'},
{'first':'Donald', 'last':'Trump',
'email':'president@whitehouse.gov'},
{'first':'Vladimir', 'last':'Putin',
'email':'president@kremvax.ru'}
]

Write a function, alphabetize_names, that assumes the existence of a PEOPLE constant defined as shown in the code. The function should return the list of dicts, but sorted by last name and then by first name.

TRY IT YOURSELF

ANSWER

https://colab.research.google.com/drive/1SRk4uZBRjvUkzPNAbmVOZBweI1CSDBBK?usp=sharing

--

--

Abish Pius
Abish Pius

Written by Abish Pius

Data Science Professional, Python Enthusiast, turned LLM Engineer

No responses yet