Stack Overflow Asked on November 7, 2021
I have a 2D list in python which contains first and last names of different people. It looks like this :
teachers=[["Rachelle", "Goodyear"],["Mike","Anderson"], ["Jeremy","Smith"]]
And I want to sort them by the length of their last name.
I’ve tried different solutions but it always sort by their first name … Please help me. Thank you.
Here is a possible solution:
sorted_teachers = sorted(teachers, key=lambda x: len(x[1]))
Answered by Riccardo Bucco on November 7, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP