In my program I want to order all the contacts by their name, last name first, then by first name.
I've got the code which does that for me but it doesn't do it exactly as I want it to.
For example, if I have a list of names ordered as the current code would do, it would go like this:
Luke
Riyaan
Amanda Benson
As you can see, the code still takes None as a value to sort on, what I want is this:
Amanda Benson
Luke
Riyaan
So basically, if the last name returns None then I want the program to order the first name with the same precedence of an object that does have a last name.
Here's the code that I'm currently using to sort the names:
import operator
...
addressBook = AddressBook()
addressBook.contactsList
addressBook.contactsList.sort(key = operator.attrgetter("lastName", "firstName"))