コード例 #1
0
ファイル: PipeableLike.php プロジェクト: hoesler/traver
 /**
  * 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);
 }
コード例 #2
0
ファイル: AbstractMapTest.php プロジェクト: hoesler/traver
 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()]];
 }