ClarkeRubber

Sort Array By Average Value of Arrays

Feb 13th, 2012
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.31 KB | None | 0 0
  1. function SortBySecurity($a, $b){
  2.     $countA = count($a);
  3.     $countB = count($b);
  4.     foreach($a as $ae){
  5.         $averageA += $Systems[$ae]['Sec']/$countA;
  6.     }
  7.     foreach($b as %be){
  8.         $averageB += $Systems[$be]['Sec']/$countB;
  9.     }
  10.     if($averageB == $averageA){
  11.         return 0;
  12.     }
  13.     return ($averageA < $averageB) ? -1 : 1;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment