[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Sorting Algorythms
In article <m27godsatl.fsf@unknown-b8-f6-b1-15-88-0d.lan>, Raymond Wiker
<rwiker@gmail.com> wrote:
> YourName@YourISP.com (Your Name) writes:
> > In article <m2bodpsr42.fsf@unknown-b8-f6-b1-15-88-0d.lan>, Raymond Wiker
> > <rwiker@gmail.com> wrote:
> >>
> >> Hmmm... I was going to ignore this post, as discussions about sorting
> >> algorithms in general is not what I read csa for, but...
> >>
> >> ... "most sorts will not sort numbers properly"?
> >>
> >> That's about the weirdest thing I've ever heard said about sorting
> >> algorithms.
> >>
> > <snip>
> >
> > I don't know about "most", but many sorting systems, including the Mac OS
> > Finder windows, don't sort numbers numerically because they use texting
> > ordering where "2" comes after "10" due to "2" being after "1". To get
> > around it you need to use "02" instead, or in the case of older Mac OS
> > versions there was an extension you could download to correct the sorting
> > order for numbers.
>
> Hmmm... first of all (and probably also "least of all" :-) - the Finder
> in current MacOs certainly sorts files with numeric parts correctly. I
> just checked with files named 1 .. 11 and File1 .. File11. (The ls
> command in /bin/bash does not, and shouldn't, because it is not expected
> to.)
I wasn't specific enough in that first sentence. The Mac OS X Finder does
sort numbers properly, but older (now called "Classic") versions don't,
which is why you needed the "Natural Order" System extension by Stuart
Cheshire ... or simply name your files with leading zeroes.
> More importantly, a key part of every sort operation is "comparison". If
> you want to sort string representations of numbers, you need a
> comparison function that works on string representations of
> numbers. This has absolutely nothing to do with the sort algorithm
> itself.
True, which is why I purposely said "sorting systems" not algorithms. :-)