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