CODE:<?php
$n[1]['name']='sergey'; $n[1]['kolvo']=15;
$n[2]['name']='ivan'; $n[2]['kolvo']=7;
$n[3]['name']='pavel'; $n[3]['kolvo']=28;
function cmp($a, $b)
{
if ($a['kolvo'] == $b['kolvo']) {
return 0;
}
return ($a['kolvo'] < $b['kolvo']) ? -1 : 1;
}
function cmp_rev($a, $b)
{
return -cmp($a, $b);
}
usort($n, 'cmp');
print_r($n);
usort($n, 'cmp_rev');
print_r($n);
?> |