Skip to content

Instantly share code, notes, and snippets.

@andjc
Forked from korakot/thaisort.py
Created February 20, 2023 10:44
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 andjc/6be24c1de1093e4bd7340f3a1b68426c to your computer and use it in GitHub Desktop.
Save andjc/6be24c1de1093e4bd7340f3a1b68426c to your computer and use it in GitHub Desktop.
Thai Sort
import icu
thkey = icu.Collator.createInstance(icu.Locale('th_TH')).getSortKey
words = 'ไก่ ไข่ ก ฮา'.split()
print(sorted(words, key=thkey)) # ['ก', 'ไก่', 'ไข่', 'ฮา']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment