On 13 December 2010 19:59, George Langley <george.lang...@shaw.ca> wrote:
> Hi all. Can use natsort($array1) to sort a single array of filenames into a 
> "natural "alphanumeric order - 1.php, 2.php, 5.php, 10.php, 20.php, etc.
> But using array_multisort($array1, $array2, $array3) doesn't offer a natsort 
> option, so I end up with 1.php, 10.php, 2.php, 20.php, 5.php, etc.
>
> Anyone have a solution to this limitation already? Nothing found in the 
> archives or Googling.
>        Thanks.
>
>
> George Langley    Multimedia Developer    Audio/Video Editor    Musician, 
> Arranger, Composer www.georgelangley.ca
>
>
>

Based upon code I found at [1] I have the following function [2] which
I use to sort result sets. I've just added natural sorting (and
natural caseless sorting) and some examples on usage.

It might be slightly over the top, but it works well for me. No need
to extract the columns from the rows to supply to the sorter.

If you like it and find any issues with it, or enhancements, then I'd
be grateful if you could pass them back to me.

Richard.


[1] http://www.php.net/manual/en/function.array-multisort.php#68452
[2] http://pastebin.com/8JsMX7yS
-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to