How many people would be interested in this feature?
On Wed, Jun 27, 2001 at 01:46:05PM +0300, [EMAIL PROTECTED] wrote:
> Brannon King wrote:
>
> >Any plans for a natural sort? A query to the effect of
> >
> >ORDER BY [~~~~~~~~~] NATURAL ASC
> >
> >or
> >
> >ORDER BY [~~~~~~~~~] NATASC
> >
> >etc.
> >
> >That would be a lot easier than bringing the data back to PHP and then
running their natsort()
>
> Can you explain in more detail what do you mean by natural sort ?
I digged a bit on PHP.net (for the first time ;-) and found the following:
http://www.php.net/manual/en/function.natsort.php
which for the algorithm refers to
http://www.linuxcare.com.au/projects/natsort/
which seems to be not reachable at the moment unfortunatly, but Google
has a cached page:
http://www.google.com/search?q=cache:GyOlzOSjQss:linuxcare.com.au/projects/n
atsort/+natsort&hl=en
The description follows:
----------------------------------------------------------------------
Strings are sorted as usual, except that decimal integer substrings
are compared on their numeric value. For example,
a < a0 < a1 < a1a < a1b < a2 < a10 < a20
Strings can contain several number parts:
x2-g8 < x2-y7 < x2-y08 < x8-y8
in which case numeric fields are separated by nonnumeric characters.
Leading spaces are ignored. This works very well for IP addresses from
log files, for example.
Numeric substrings with leading zeros are considered to be fractional:
1.001 < 1.002 < 1.010 < 1.02 < 1.1 < 1.3
Performance is linear: each character of the string is scanned at most
once, and only as many characters as necessary to decide are
considered.
[...]
Related Work
POSIX sort(1) has the -n option to sort numbers, but this doesn't work
if there is a non-numeric prefix.
GNU ls(1) has the --sort=version option, which works the same way.
Stuart Cheshire's Macintosh program to do natural ordering. I already
had the idea of this routine, but borrowed the term ``natural
sort''. Article about this in a Mac magazine.
----------------------------------------------------------------------
Hope this helps,
Benjamin ([EMAIL PROTECTED])
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php