There are still various unclear points (you are not saying exactly the output you want) but sort -g
should do it:
$ cat s.txt
FOO.A1
FOO.A1-1
FOO.A2
FOO.A3
FOO.A10
BAR.A1
BAR.B1
BAR.B1-1
$ sort -g s.txt
BAR.A1
BAR.B1
BAR.B1-1
FOO.A1
FOO.A1-1
FOO.A10
FOO.A2
FOO.A3
-g
is defined as such:
-g, --general-numeric-sort, --sort=general-numeric
Sort by general numerical value. As opposed to -n, this option handles general floating points. It has a more permissive format than that allowed by -n but it has a significant performance drawback.
But -n
would fit here as well, so your desired output is not clear.
Based on your further updates, maybe this is what you want:
$ sort -t '.' -k 2 -V < s.txt
BAR.A1
FOO.A1
FOO.A1-1
FOO.A2
FOO.A3
FOO.A10
BAR.B1
BAR.B1-1