Skip to content

Instantly share code, notes, and snippets.

@cokernel
Last active September 30, 2022 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cokernel/c08bd670e2e2bc50c1af358e647f4879 to your computer and use it in GitHub Desktop.
Save cokernel/c08bd670e2e2bc50c1af358e647f4879 to your computer and use it in GitHub Desktop.
Sort numerals 1-99 alphabetically by English name.
#!/usr/bin/env perl
@l=(z,one,two,thir,four,five,six,seven,eigh,nine,ten,eleven,twelve);for(sort{e($a)cmp e($b)}1..99){print"$_\n"}sub e{$_=$_[0];($j,$d)=/./gs;$_<13?$_=$l[$_]:$j<2?$_=($l[$d].'teen'):($_=$l[$j].'ty'.($d?'-'.e($d):''))=~s/u//;s/h$/ht/;s/vet/ft/;s/ot/ent/;s/ir$/ree/;$_}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment