HH\Lib\Vec\sort_by

This API is part of the Hack Standard Library, not HHVM itself.
Facebook Engineer?

This function is available as Vec\sort_by() in Facebook's www repository.

Returns a new vec sorted by some scalar property of each value of the given Traversable, which is computed by the given function

Description

namespace HH\Lib\Vec;

function sort_by<Tv, Ts>(
  Traversable<Tv> $traversable,
  (function(Tv):Ts) $scalar_func,
  ?(function(Ts,Ts):int) $comparator = null,
): vec<Tv>;

If the optional comparator function isn't provided, the values will be sorted in ascending order of scalar key.

To sort by the values of the Traversable, see Vec\sort().

Parameters