Sort csv file

Hello,

I am facing the following problem:
I have a file in csv format. So several records where data fields are separated by comma ','
The lenght of the fields is variable, as well as the number of fields per record. But there are at least 7 fields per record.
I need to sort the file based on the 7th field.
For instance

123,HELLO,,XX,,1,9,BABA,HINT
923,HI,K,ZZ,B,1,3,,,,,TWO
4,,,,,,1,

Once sorted should give:

4,,,,,,1,
923,HI,K,ZZ,B,1,3,,,,,TWO
123,HELLO,,XX,,1,9,BABA,HINT

Thanks,
BSF

$ sort -t',' +6n infile
1 Like