7 Comments
User's avatar
⭠ Return to thread
Paul's avatar

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))

Expand full comment
Stephen Gruppetta's avatar

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!

Expand full comment