students = ["Merol B Joseph", "Ferzil Babu", "Basil Abraham", "Kiran Baby", "Ziya sofia"] x = sorted(students, key=lambda name: name.split(" ")[-1].lower()) print x print students