How to sort lines of files on Linux by just the first character

If you need to order a file just by the first character then you can use this command:

$ sort -k1.1,1.1 filename

It will show the result in the standard output, then append “> newfile” to above command to create a new file with sorted lines.