fork download
  1. <?php
  2.  
  3. class ReportController {
  4. public function complements()
  5. {
  6. $dishes =
  7. [
  8. 'a' => ['count' => 200, 'more' => 'qwerty'],
  9. 'b' => ['count' => 300, 'more' => 'qwerty'],
  10. 'c' => ['count' => 100, 'more' => 'qwerty'],
  11. ];
  12.  
  13. uasort($dishes, [self::class, 'cmp']);
  14. print_r($dishes);
  15. }
  16.  
  17. private function cmp($a, $b) {
  18. return $a <=> $b;
  19. }
  20. }
  21.  
  22. (new ReportController)->complements();
Success #stdin #stdout 0.02s 24308KB
stdin
Standard input is empty
stdout
Array
(
    [c] => Array
        (
            [count] => 100
            [more] => qwerty
        )

    [a] => Array
        (
            [count] => 200
            [more] => qwerty
        )

    [b] => Array
        (
            [count] => 300
            [more] => qwerty
        )

)