rank<T extends Comparable<Object> > function
Returns a Float64List with the competition rank of each element in
values (defaulting to ascending), with double.nan for unorderable
elements.
Implementation
// DIVERGES(d3-array): adapt-array-typed-api, split rank, rankNullable,
// rankWith, and rankBy instead of JS arity sniffing.
// DIVERGES(d3-array): adapt-array-fast-forms, unboxed 3-way index quicksort
// for Float64List and List<double> avoiding closure dispatch and boxing.
Float64List rank<T extends Comparable<Object>>(
Iterable<T> values, [
num Function(T a, T b)? compare,
]) {
if (compare == null) {
final Object raw = values;
if (raw is Float64List) return _rankDoubleList(raw);
if (raw is List<double>) return _rankDoubleList(raw);
final list = values is List<T>
? values
: List<T>.of(values, growable: false);
return _rankWith<T>(list, ascending<T>, ascendingDefined<T>);
}
final list = values is List<T> ? values : List<T>.of(values, growable: false);
return _rankWith<T>(list, compare, compareDefined<T>(compare));
}