<?php
$arr=[['a', 1, 3, 9, 0, 13],['b', 5, 6, 0, 0, 11],['j', 0, 6, 2, 1, 9],['c', 1, 0, 8, 5, 14],['d', 0, 0, 0, 17, 17],['e', 0, 5, 0, 0, 5],['h', 0, 0, 3, 3, 6]];
usort($arr,function($a,$b){
$infoa=array_count_values($a);
$infob=array_count_values($b);
if(empty($infoa[0])) $infoa[0]=0;
if(empty($infob[0])) $infob[0]=0;
if($infoa[0]==$infob[0])
{
return end($a)-end($b);
}
else
{
return $infoa[0]-$infob[0];
}
});
print_r($arr);
preferences:
43.64 ms | 402 KiB | 5 Q