Add "LC_ALL=C" before every call to "sort".