Sorting strings by respecting natural order for numbers - 6 octobre 2012
A function that is useful is a comparator of strings (for sorting purpose, in general) that respect the natural order of numbers.
So when we have a list of strings, like file names, for examples, with numbers in them, it is better to respect the numerical order when strings are equal.
A common case is numbered names: a trivial, lexicographical order would be:
foo-1
foo-10
foo-11
foo-2
...
foo-9
where one expects:
foo-1
foo-2
...
foo-9
foo-10
foo-11
I show here how to do such comparator.
Continuer à lire "Sorting strings by respecting natural order for numbers"
« Page précédente
(Page 1 sur 1 avec 1 billets au total)
Page suivante »