Exemplo n.º 1
0
 public function testSort()
 {
     $array = [1, 2, 3, 4, 5];
     $seq = new Sequence($array);
     $this->assertEquals([1, 2, 3, 4, 5], $seq->sort()->toArray());
     $this->assertEquals($array, $seq->toArray());
     //check that original colection is unaltered
     $this->assertEquals([5, 4, 3, 2, 1], $seq->sort(function ($a, $b) {
         return $a === $b ? 0 : $a > $b ? -1 : 1;
     })->toArray());
 }