Использование uasort()
:
<?php
$hello = array(
'text' => array('name' => 'blabla', 'num' => 10),
'sometext' => array('name' => 'blabla', 'num' => 2),
'anytext' => array('name' => 'blabla', 'num' => 1)
);
function sort_func($x, $y) { // our custom sorting function
if($x['num'] == $y['num'])
return 0; // zero return value means that the two are equal
else if($x['num'] < $y['num'])
return -1; // negative return value means that $x is less than $y
else
return 1; // positive return value means that $x is more than $y
}
uasort($hello, 'sort_func');
echo '<ul>';
foreach($hello as $key => $value)
{
echo '<li>'.htmlspecialchars($key).'</li>';
}
echo '</ul>';