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.

5
  • This question might help. It is about rotating the data 90 degrees, i.e. transposition -- Transpose a file in bash. Once you can get it transposed, sorting is trivial. Commented Aug 26, 2014 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. Commented Aug 26, 2014 at 13:47
  • This question has been marked as duplicated. So there are no other ways to solve this other that transposing the data? Commented Aug 26, 2014 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. Commented Aug 26, 2014 at 13:54
  • 1
    I just posted a non-transposey answer to the linked duplicate question, see if you find it useful. Commented Aug 26, 2014 at 14:28

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.