When sorting in bash, the locale can interfere with a strict lexicographical sort order. The solution is to temporarily reset the locale of the shell.
As an example, a strict lexicographical directory listing -
<span class="s1">ls | LC_ALL=C sort</span>