Mang G11
Mang G11

Reputation: 219

Linux sort - not sorting properly?

I have a big file with 2 columns. Words and Numbers. i want to sort by the second column numerically.

I run this command:

sort -k2 words.txt

and I get this result:

Release 99
Some    99
tmc     99
watcher 99
no      990
in      9909
one     992

I want this to be sorted numberically. Why does it have "in 9909" as second last?

tia!

Upvotes: 2

Views: 2378

Answers (1)

Oliver Charlesworth
Oliver Charlesworth

Reputation: 272752

You also need the -n flag to perform a numeric sort rather than a lexicographic sort.

Upvotes: 6

Related Questions