HH\Lib\Dict\sort_by

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

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

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

Description

namespace HH\Lib\Dict;

function sort_by<Tk as arraykey, Tv, Ts>(
  KeyedTraversable<Tk, Tv> $traversable,
  (function(Tv):Ts) $scalar_func,
  ?(function(Ts,Ts):int) $scalar_comparator = null,
): dict<Tk, 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 KeyedTraversable, see Dict\sort(). To sort by the keys of the KeyedTraversable, see Dict\sort_by_key().

Parameters