sorting - Linux sort utility, possible to sort on minimum value of multiple columns? -


a text file has multiple columns of 1 "start" , other "end", both holding positive integer values. however, since objects described (think of them vectors placed on number line) have direction these can end in either orientation this:

 400  20  (start @ 400, end @ 20)   10 100  (start @ 10, end @ 100 )  300  15  (start @ 300, end @ 15) 

often 1 order these ranges, opposed start or end value. range limits row are:(min(start,end), max(start,end)). sorting lower limit give order:

  10 100  (start @ 10, end @ 100 )  300  15  (start @ 300, end @ 15)  400  20  (start @ 400, end @ 20) 

this type of sort can accomplished using perl or other similar scripting language, first generating lower range limit, , sorting on it. however, far can tell there no way directly using usual unix/linux sort utility. specifying this:

sort -k 1,1n -k 2,2n 

sorts on first, if there tie, sorts on second. isn't desired sort though.

is there way type of "minimum of multiple column" sort using "sort"?


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -