1

I'd like to do a left-to-right sort, instead of top to bottom sort as people normally do. Are there any simple command to this in bash other than transposing the data back and forth? In my opinion, transposing data will add unnecessary complexity to the code.

Here is the input

Carol   Adam    Dean    Bills
0.88    0.57    0.43    0.70
black   green   white   purple

And here is the sorted result based on the data in the first row

Adam    Bills   Carol   Dean
0.57    0.70    0.88    0.43
green   purple  black   white

I don't think this kind of problem is uncommon so I've google and search in this stackoverflow but I couldn't find any simple solutions.

Jessada Thutkawkorapin
  • 1,336
  • 3
  • 16
  • 32
  • This question might help. It is about rotating the data 90 degrees, i.e. transposition -- [Transpose a file in bash](http://stackoverflow.com/q/1729824/1328439). Once you can get it transposed, sorting is trivial. – Dima Chubarov Aug 26 '14 at 13:43
  • I've noticed that as well. From coding perspective, it's a little complicated going back and forth to something not that much complex. I just hoped that there might be a simpler way. – Jessada Thutkawkorapin Aug 26 '14 at 13:47
  • This question has been marked as duplicated. So there are no other ways to solve this other that transposing the data? – Jessada Thutkawkorapin Aug 26 '14 at 13:49
  • 1
    The duplication does not mean that there is just one way to do it. It is a way to indicate that this question was already asked in a very similar way, so that future readers and answerers should concentrate their efforts in the original one. – fedorqui Aug 26 '14 at 13:54
  • 1
    I just posted a [non-transposey answer](http://stackoverflow.com/a/25508350/240443) to the linked duplicate question, see if you find it useful. – Amadan Aug 26 '14 at 14:28

0 Answers0