I'm trying to sort a list of tuples based on the last names:
names = [
(123, 'Active', 'Michael Wilson Blessing'),
(456, 'Active', 'Tim Weaver Beadle'),
(789, 'Active', 'Lois Alan Beadle'),
...
]
What I want to do is sort this list based on last name. To accomplish this, I used
otherlist = sorted(otherlist, key=lambda x: x[2])
which works for unique last names, but for duplicates such as 'Beale', it seems to not want to sort it how it should, where if there's a match on last name to utilize the first name (i.e., Michael Blessing, Lois Beadle, Time Beadle). Is there a way to configure this with just the lambda, or do I need to just create a function that accomplishes this, and what might that look like?
