<?php
/*function sortByLength($a,$b){
return strlen($b)-strlen($a);
}
$array = array("bbbbb", "dog", "cat", "aaa", "aaaa");
echo usort($array,'sortByLength');
// print_r($sorted);*/
$priorities = array(5, 8, 3, 7, 3);
usort($priorities, function($a, $b)
{
if ($a == $b)
{
echo "a ($a) is same priority as b ($b), keeping the same\n";
return 0;
}
else if ($a > $b)
{
echo "a ($a) is higher priority than b ($b), moving b down array\n";
return -1;
}
else {
echo "b ($b) is higher priority than a ($a), moving b up array\n";
return 1;
}
});
echo "Sorted priorities:\n";
var_dump($priorities);