So, I am confused by this sort routine
Posted: 05 Apr 2011 21:01
Source :Sorting text with numbers - Sorting that handles numbers as numbers not text
So , the little help text says
It says "n" specifies the position of character to start sorting. So let's say we have this in a file
without specifying the "n" character, it gives supposedly correct results
However, when tested with n = 4 for example
this gives incorrect results, since starting from 4th position, these should be the correct result
Some one please clear up my confusion.
So , the little help text says
Code: Select all
...
test [n]
n Specifies the character number, n, to
begin each comparison. 3 indicates that
each comparison should begin at the 3rd
character in each line. Lines with fewer
than n characters collate before other lines.
By default comparisons start at the first
character in each line.
It says "n" specifies the position of character to start sorting. So let's say we have this in a file
Code: Select all
abc10def3
abc900def4
abc29def3
ab2234defa
ab2234defv
without specifying the "n" character, it gives supposedly correct results
Code: Select all
C:\work>type file | test.bat
ab2234defa <== since "2" is at 3rd position
ab2234defv <=== since "v" is greater than "a" at the last position
abc10def3
abc29def3 <=== the rest are at 4th position
abc900def4
However, when tested with n = 4 for example
Code: Select all
C:\work>type file | test.bat 4
abc10def3
abc900def4 <=== why is 900 here ie, greater than "29" below?
abc29def3
ab2234defa
ab2234defv
this gives incorrect results, since starting from 4th position, these should be the correct result
Code: Select all
abc10def3 <== starting from 4th position "10" is smallest
abc29def3 <=== then 29
ab2234defa <== then 234
ab2234defv <== then 234 and last character "v" is greater than previous "a"
abc900def4 <== 900 is the highest.
Some one please clear up my confusion.