Ejemplo n.º 1
0
 public function testSort()
 {
     $array = ["d" => 8, "e" => -1, "b" => 0];
     $map = new Map($array);
     $this->assertEquals(["e" => -1, "b" => 0, "d" => 8], $map->sort()->toArray());
     $this->assertEquals($array, $map->toArray());
     //check that original colection is unaltered
     $this->assertEquals(["d" => 8, "b" => 0, "e" => -1], $map->sort(function ($a, $b) {
         return $a === $b ? 0 : $a > $b ? -1 : 1;
     })->toArray());
 }