bisectRightBy<T, V extends Comparable<Object> > function
Returns the insertion index for value in list to maintain sorted order.
Uses the rightmost position for equal values.
Uses an accessor function to extract comparable values.
Implementation
int bisectRightBy<T, V extends Comparable<Object>>(
List<T> list,
V value,
V Function(T) accessor, {
int lo = 0,
int? hi,
}) {
var hiValue = hi ?? list.length;
while (lo < hiValue) {
final mid = (lo + hiValue) ~/ 2;
if (accessor(list[mid]).compareTo(value) > 0) {
hiValue = mid;
} else {
lo = mid + 1;
}
}
return lo;
}