Skip to main content
deleted 32 characters in body
Source Link
Rui F Ribeiro
  • 58k
  • 28
  • 156
  • 239

I've got two columns of data I need to sort: the first column(A) needs to be sorted lexicographically and for any rows which then contain the same column A string, I need them to be sorted numerically according to what's in the second column(B).

I was thinking 'sort -f' , but that would make a '12' in column B come before a '2'.

Any help is appreciated (:

Edit: Accidentally typed column in place of row.

I've got two columns of data I need to sort: the first column(A) needs to be sorted lexicographically and for any rows which then contain the same column A string, I need them to be sorted numerically according to what's in the second column(B).

I was thinking 'sort -f' , but that would make a '12' in column B come before a '2'.

Any help is appreciated (:

Edit: Accidentally typed column in place of row.

I've got two columns of data I need to sort: the first column(A) needs to be sorted lexicographically and for any rows which then contain the same column A string, I need them to be sorted numerically according to what's in the second column(B).

I was thinking 'sort -f' , but that would make a '12' in column B come before a '2'.

Edit: Accidentally typed column in place of row.

Source Link
Anj
  • 43
  • 4

Can you sort one column lexicographically while simultaneously sorting the next column numerically?

I've got two columns of data I need to sort: the first column(A) needs to be sorted lexicographically and for any rows which then contain the same column A string, I need them to be sorted numerically according to what's in the second column(B).

I was thinking 'sort -f' , but that would make a '12' in column B come before a '2'.

Any help is appreciated (:

Edit: Accidentally typed column in place of row.