Exemplo n.º 1
0
 /**
  * Implements {@link Pipeable::sort}.
  * @param callable|null $compareFunction
  * @return PipeableLike
  */
 public function sort(callable $compareFunction = null)
 {
     if ($compareFunction === null) {
         $compareFunction = Comparators::naturalComparator();
     }
     $array = $this->toArray();
     $success = uasort($array, $compareFunction);
     if ($success === false) {
         throw new \RuntimeException("sort failed");
     }
     return $this->newCollection($array);
 }
Exemplo n.º 2
0
 public function sortProvider()
 {
     return [[[1, 2, 4, 3], [1, 2, 3 => 3, 2 => 4]], [[1, 2, 4, 3], [1, 2, 3 => 3, 2 => 4], Comparators::naturalComparator()]];
 }