/** * @chainable * @category Arrays * @param array $xs * @param callable $compare * @return Iterator */ public static function sort($xs, $compare = null) { return new Iterator\DeferIterator(function () use($xs, $compare) { return new \ArrayIterator(ArrayImpl::sort($xs, $compare)); }); }
/** * @chainable * @category Arrays * @param array $xs * @param callable $compare * @return Generator */ public static function sort($xs, $compare = null) { foreach (ArrayImpl::sort($xs, $compare) as $x) { (yield $x); } }