in src/c/order.php [80:103]
function is_sorted_by<Tv, Ts>(
Traversable<Tv> $traversable,
(function(Tv)[_]: Ts) $scalar_func,
?(function(Ts, Ts)[_]: num) $comparator = null,
)[ctx $scalar_func, ctx $comparator]: bool {
$vec = Vec\cast_clear_legacy_array_mark($traversable);
if (is_empty($vec)) {
return true;
}
$comparator ??= (Ts $a, Ts $b) ==>
/*HH_FIXME[4240] Comparison may not be useful on Ts*/$a <=> $b;
$previous = $scalar_func(firstx($vec));
foreach ($vec as $next) {
$next = $scalar_func($next);
if ($comparator($next, $previous) < 0) {
return false;
}
$previous = $next;
}
return true;
}