Hi, I really liked your article. Never realised that keys can be supplied in so many places!
Please note that instead of sorting twice to get a list of names sorted on nr of 'a's and names with equal nr of 'a's alphabetically , you could sort just once:
Hi, I really liked your article. Never realised that keys can be supplied in so many places!
Please note that instead of sorting twice to get a list of names sorted on nr of 'a's and names with equal nr of 'a's alphabetically , you could sort just once:
And yes, you make a great point about returning a tuple in the `lambda`. This would require a discussion about ordering in tuples, too, but it would avoid one of the `.sort()` calls!
Hi, I really liked your article. Never realised that keys can be supplied in so many places!
Please note that instead of sorting twice to get a list of names sorted on nr of 'a's and names with equal nr of 'a's alphabetically , you could sort just once:
sort_names.sort(key=lambda x: (x.lower().count('a'), x))
Thanks Paul. Glad you enjoyed it.
And yes, you make a great point about returning a tuple in the `lambda`. This would require a discussion about ordering in tuples, too, but it would avoid one of the `.sort()` calls!