Q:

php sorting long strings in php

I have a directory listing that I need to sort. so far natsort works well except when a decimal is introduced.  009 comes after 009.1 I am trying to work on getting all the special char's out of the directory names and havent had issues with them so far.  "http://10.1.1.1/manual/product/v02/secton 3/part 3.1 leveling/002.jpg"  some get as long as 150 or so char's long. Since these are long strings with occasional decimals its not easy to get them properly sorted. I dont believe . are used any where except for decimals and the file extension
Every thing I have read so far ignores decimals.  0200 is before 100 in cases like that I would hope that specials would come after # and letters but appairently not. 

A:

Given that you have sorting requirements that can't be met by any existing PHP functions, your best bet is to call usort() and write your own comparison function.
Sample
function cmp($a, $b)
{
    return strcmp($a, $b); # replace with your own comparison logic
}
usort($array, 'cmp');

