Use special csort to ensure cross-platform order

Previously we set the locale across all scripts to force the sort order,
but this broke unicode handling in $stdin. Therefore we need to isolate
the locale change to a specific sort command.