unix sort treats '-' (dash) characters as invisible

Solution 1:

The sort order behaviour of sort(1) is controlled by your locale settings (see man locale).

There are a number of different locale settings, for example:

$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
...
LC_ALL=

To choose the desired sort behaviour, you need to choose the correct LC_COLLATE value. In this case, the standard built in C (POSIX) locale is suitable:

$ sort testcase
aa
a-b
ac

$ LC_COLLATE=C sort testcase
a-b
aa
ac

If you prefer, you can set all the locale settings (thus being more consistent) by setting LC_ALL=C. Since these are environment variables, you can permanently set your sort order, with export LC_ALL=C or similar, in your shell startup script.

Solution 2:

setting environment variable LC_ALL=C changes the behavior of sort. The default locale sort order must be treating '-' specially.