Skip to content

Instantly share code, notes, and snippets.

@Shogun89
Created February 19, 2024 23:33
Show Gist options
  • Save Shogun89/e16c4c26b47a89373186fa02e7400d5d to your computer and use it in GitHub Desktop.
Save Shogun89/e16c4c26b47a89373186fa02e7400d5d to your computer and use it in GitHub Desktop.
Orders list of numbers by their word version
from num2words import num2words
numbers = list(range(10,100))
number_to_word_dict = {num : num2words(num) for num in numbers}
sorted_numbers = sorted(numbers, key = lambda x : number_to_word_dict[x])
print(sorted_numbers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment