HH\Lib\Vec\sort
Requires the Hack Standard Library to be installed.
Facebook Engineer?
This function is available as Vec\sort()
in Facebook's www repository.
Returns a new vec sorted by the values of the given Traversable
namespace HH\Lib\Vec;
function sort<Tv>(
Traversable<Tv> $traversable,
?(function(Tv, Tv): int) $comparator = NULL,
): vec<Tv>;
If the optional comparator function isn't provided, the values will be sorted in ascending order.
To sort by some computable property of each value, see Vec\sort_by()
.
Time complexity: O((n log n) * c), where c is the complexity of the comparator function (which is O(1) if not provided explicitly) Space complexity: O(n)
Parameters
Traversable<Tv> $traversable
?(function(Tv, Tv): int) $comparator = NULL
Returns
vec<Tv>