You are not logged in.
I was wondering if there is a program out there, or some text file I have to edit that could make it so that when my computer is sorting (regardless of what program I am using), that it will recognize that 2 comes before 10, 100, 132123, etc... It's very frustrating to have to change all my numbers to "0000001" in order for the computer to sort them correctly. A big thanks to anyone that knows how to do this!
Offline
Recognising them in what?
Not a GNU/Linux discussion, moving to NC...
Offline
The easiest way to sort numbers would probably be to just use "sort". It has a flag -n, which will make it sort according to the numerical values instead of alphabetically.
Example of processing a file nums.txt:
cat nums.txt
10
100
132123
2
cat nums.txt | sort
10
100
132123
2
cat nums.txt | sort -n
2
10
100
132123
This is what you wanted, correct?
Offline
Offline
Thanks for moving it jason, I was debating between the two threads. Though to answer you question... I want them recognized that way in my entire GNU/Linux system.
nachosduyo, yes, that's what I am looking for, but I want that to happen across my whole GNU/Linux system by default for all programs (which is why I initially put this under GNU/Linux discussion).
I think this is a system issue, and that no one actually wants numbers sorted "10, 100, 132123, 2..." no matter the issue (I would love for someone to tell me a case where you would want this, I would be interested).
Offline
It depends on your collation settings, which are part of the locale.
$ sort -n n
!
@
a
A
b
B
2
10
100
132123
$ LC_ALL=C sort -n n
!
@
A
B
a
b
2
10
100
132123
Offline
Please read this document and return here, when you have absorbed and understood the information.
EDIT:
Fixed link.
Last edited by Awebb (2015-07-25 23:40:30)
Offline