Sorting a group of data based on a column

I have an input file containing the following data:

1 2 3 4
  4   6
  8   9
      10
2 1 5 7
  3
3 4 2 9
  2   7
      11

      

I am trying to execute a sort

group of data based on the third column and get an output like this:

2 1 5 7
  3
1 2 3 4
  4   6
  8   9 
      10
3 4 2 9
  2   7
      11

      

Could you please tell me how to do this?

+3


source to share


1 answer


sort -nk3r

      

will sort in reverse order based on the third column. Note, however, that this outputs



2 1 5 7
1 2 3 4
3 4 2 9
      10
      11
  2   7
  3
  4   6
  8   9

      

because of the bash sorting way, and this results in a different result than the result you posted, but correct according to the question.

0


source







All Articles