Skip to content

Instantly share code, notes, and snippets.

@stephengruppetta
Created December 7, 2023 09:29
Show Gist options
  • Save stephengruppetta/f94d39e4e966420d3f7128ca767172de to your computer and use it in GitHub Desktop.
Save stephengruppetta/f94d39e4e966420d3f7128ca767172de to your computer and use it in GitHub Desktop.
some_names = [
"Robert",
"Ishaan",
"Max",
"Trevor",
"Alexandra",
"Albert",
"Christine",
]
# First order alphabetically
some_names.sort()
# Then order by number of 'a's
some_names.sort(
key=lambda item: item.lower().count("a")
)
print(*some_names, sep="\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment