Instead of searching Google for answers about how a utility works, try reading the man page for that utility on your system. In this case try the command:
man sort
to see the man page for the sort
utility on your system. The behavior of lots of utilities varies from system to system. What you find on Google MIGHT or MIGHT NOT explain how the utility you're searching for will work on your system; the man page on your system WILL explain how the utility will work on your system.
If the man page on your system doesn't answer your question, or you don't understand what some of the words on the man page on you system mean; create a sample data file and try sorting with sort file
(which your man page will explain performs an alphanumeric sort) and sort -n file
(which your man page will explain performs a numeric sort). For example, if file
contains:
sa003 hekk
ASA341 no more
asa012 try a d g
ASA001 a
asa111 this is just a sample for long string
000aaa note that a numeric sort treats sort keys starting with text as zero.
000AAA NOTE THAT A NUMERIC SORT TREATS SORT KEYS STARTING WITH TEXT AS ZERO.
001asa003 hekk
100hasa341 no more
100asa012 try a d g
002asa001 a
039asa111 this is just a sample for long string
101sdfc
099sdfs
999
1441
102
1000
then an alphanumeric sort ( sort file
) produces:
000AAA NOTE THAT A NUMERIC SORT TREATS SORT KEYS STARTING WITH TEXT AS ZERO.
000aaa note that a numeric sort treats sort keys starting with text as zero.
001asa003 hekk
002asa001 a
039asa111 this is just a sample for long string
099sdfs
1000
100asa012 try a d g
100hasa341 no more
101sdfc
102
1441
999
ASA001 a
ASA341 no more
asa012 try a d g
asa111 this is just a sample for long string
sa003 hekk
while a numeric sort ( sort -n file
) produces:
000AAA NOTE THAT A NUMERIC SORT TREATS SORT KEYS STARTING WITH TEXT AS ZERO.
000aaa note that a numeric sort treats sort keys starting with text as zero.
ASA001 a
ASA341 no more
asa012 try a d g
asa111 this is just a sample for long string
sa003 hekk
001asa003 hekk
002asa001 a
039asa111 this is just a sample for long string
099sdfs
100asa012 try a d g
100hasa341 no more
101sdfc
102
999
1000
1441
If you can't figure out why your examples aren't working the way you think they should, show us the sample input you used, the output you got, the code you used to transform that sample input to the output you got, show us the output you wanted to get (or expected to get), and explain what you didn't understand on the man page or what you were trying to do that didn't work.
We will be happy to help you figure out how to use the tools available on your system; we will quickly get tired of being asked to do someone else's work for them if they don't seem to be interested in learning how to do it on their own.