мой массив списка
Array ( [0] => Array ( [id] => 1000044375809533 [likes] => 10 [comments] => 6 [posts] => 41 [gender] => female ) [1] => Array ( [id] => 1000043758049533 [likes] => 10 [comments] => 6 [posts] => 41 [gender] => male ) [2] => Array ( [id] => 1000040382928633 [likes] => 4 [comments] => 0 [posts] => 0 [gender] => female ) [3] => Array ( [id] => 1000003829428633 [likes] => 4 [comments] => 0 [posts] => 0 [gender] => male ) )
Как установить список по полу?
А потом сортировать по "total = likes + comments + posts"
total = 10 gender = мужчина
total = 8 gender = мужчина
всего 10 пол = женщина
total = 7 gender = женщина
Использовать usort()
function cmp($a, $b) { if ($a['gender'] == $b['gender']) { return 0; } return ($a['gender'] < $b['gender']) ? -1 : 1; } usort($array, "cmp");