I tried your example for sorting from largest to smallest:
cat dictionary.txt | awk '{ print length, $0 }' | sort -g -r | cut -d" " -f2 > sorted_dictionary.txt
with the example text:
A
A รหัส A
AB
ABC
and the result is:
A
ABC
AB
A
with "รหัส A" deleted.
A possible kludge that I came up is:
cat dictionary.txt | awk '{ print length, $0 }' | sort -g -r | sed 's/^ *//' | cut -d" " -f2- > sorted_dictionary.txt