sort with -k greater than number of keys

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I'm trying to understand an existing script used in our project with the sort command
sort -t= -nr -k3 nos
Where nos is a file with whitespace and numbers, for this example:
997 998 999 1000
The output is
999
998
997
1000
What I don't understand is why 1000 appears last. I suspect it is because of the argument -k3 when there is only key for each entry but I can't find anything in the documentation to say how it behaves when the specified key position doesn't exist.
Up until 4-digit numbers were included in the file this gave the expected result of sorting the numbers descending numerically.
sort
New contributor
Chris R is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
0
down vote
favorite
I'm trying to understand an existing script used in our project with the sort command
sort -t= -nr -k3 nos
Where nos is a file with whitespace and numbers, for this example:
997 998 999 1000
The output is
999
998
997
1000
What I don't understand is why 1000 appears last. I suspect it is because of the argument -k3 when there is only key for each entry but I can't find anything in the documentation to say how it behaves when the specified key position doesn't exist.
Up until 4-digit numbers were included in the file this gave the expected result of sorting the numbers descending numerically.
sort
New contributor
Chris R is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm trying to understand an existing script used in our project with the sort command
sort -t= -nr -k3 nos
Where nos is a file with whitespace and numbers, for this example:
997 998 999 1000
The output is
999
998
997
1000
What I don't understand is why 1000 appears last. I suspect it is because of the argument -k3 when there is only key for each entry but I can't find anything in the documentation to say how it behaves when the specified key position doesn't exist.
Up until 4-digit numbers were included in the file this gave the expected result of sorting the numbers descending numerically.
sort
New contributor
Chris R is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I'm trying to understand an existing script used in our project with the sort command
sort -t= -nr -k3 nos
Where nos is a file with whitespace and numbers, for this example:
997 998 999 1000
The output is
999
998
997
1000
What I don't understand is why 1000 appears last. I suspect it is because of the argument -k3 when there is only key for each entry but I can't find anything in the documentation to say how it behaves when the specified key position doesn't exist.
Up until 4-digit numbers were included in the file this gave the expected result of sorting the numbers descending numerically.
sort
sort
New contributor
Chris R is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Chris R is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Chris R is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 5 mins ago
Chris R
1011
1011
New contributor
Chris R is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Chris R is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Chris R is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Chris R is a new contributor. Be nice, and check out our Code of Conduct.
Chris R is a new contributor. Be nice, and check out our Code of Conduct.
Chris R is a new contributor. Be nice, and check out our Code of Conduct.
Chris R is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f476376%2fsort-with-k-greater-than-number-of-keys%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password