Sort by last name
Input
sort_names_by_last(['Ada Lovelace', 'Alan Turing', 'Grace Hopper'])
Output
['Grace Hopper', 'Ada Lovelace', 'Alan Turing']
Last names: Hopper, Lovelace, Turing -> Hopper, Lovelace, Turing
Full lesson preview
Use sorted with a lambda key that extracts the last name to sort a list of full names.
Problem statement
Task
Examples
Input
sort_names_by_last(['Ada Lovelace', 'Alan Turing', 'Grace Hopper'])
Output
['Grace Hopper', 'Ada Lovelace', 'Alan Turing']
Last names: Hopper, Lovelace, Turing -> Hopper, Lovelace, Turing
Input format
Output format
Constraints
Samples
Input
sort_names_by_last(['Plato', 'Socrates', 'Aristotle'])
Output
['Aristotle', 'Plato', 'Socrates']
Single-word names are sorted alphabetically by that 'last' word.