php sort multidimensional array by alphanumeric value
<p>I'm looking for a custom function that will respect the order of the array and sort it by the 'name' index. 'strcasecmp()' function doesn't understand alphanueric values as humans would read it. It thinks 'Apples 12' is a lesser value than 'Apples 5'. I tried this method but cant find a function to compare alphanumeric value:</p>

<pre><code>$array = array(
    0 =&gt; array(
        'id' =&gt; 2,
        'type' =&gt; 'Apples',
        'name' =&gt; 'Apples 5',
    ),
    1 =&gt; array(
        'id' =&gt; 3,
        'type' =&gt; 'Grapes',
        'name' =&gt; 'Apples',
    ),
    2 =&gt; array(
        'id' =&gt; 4,
        'type' =&gt; 'Apples',
        'name' =&gt; 'Apples 4',
    ),
    3 =&gt; array(
        'id' =&gt; 5,
        'type' =&gt; 'Grapes',
        'name' =&gt; 'Apples 01',
    ),
    4 =&gt; array(
        'id' =&gt; 6,
        'type' =&gt; 'Apples',
        'name' =&gt; 'Apples 1',
    ),
    5 =&gt; array(
        'id' =&gt; 7,
        'type' =&gt; 'Grapes',
        'name' =&gt; 'Apples 12',
    )
);

uasort($array, function($a, $b) {
    return strcasecmp($a['name'], $b['name']);
});

foreach($array as $single) {
    echo $single['name'].'&lt;br /&gt;';
}
</code></pre>

<p>Unexpected result from code above:</p>

<pre><code>Apples
Apples 01
Apples 1
Apples 12
Apples 4
Apples 5
</code></pre>

<p>The result I wanted to achieve:</p>

<pre><code>Apples
Apples 01
Apples 1
Apples 4
Apples 5
Apples 12
</code></pre>

<p>Any ideas?</p>
