sorting a file by column, possible values are number, Inf, -Inf, NA

1

I have a tab-separated ASCII file.

One of the columns contains numbers which always have a decimal point (like 0.311225363556077).

However, in this column entries might also be any one of these strings:

Inf
-Inf
NA

I would like to sort the lines of this file, by the value in that column. How can I do that?

I was thinking about using (GNU) sort, but I can't figure out if it recognizes Inf and -Inf properly.

The sort order should be: from top to bottom: Inf, numbers in order, -Inf, NA

This is on Debian.

user50105

Posted 2012-06-28T05:56:40.297

Reputation:

Answers

2

Assume that the corresponding column is 2.

cat input |sort -k2 -g -r

Aris Sotiropoulos

Posted 2012-06-28T05:56:40.297

Reputation: 36