bisectLeftBy<T, V extends Comparable<Object> > function
Returns the insertion index for value in list to maintain sorted order.
Uses the leftmost position for equal values.
Uses an accessor function to extract comparable values.
Implementation
int bisectLeftBy<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) {
lo = mid + 1;
} else {
hiValue = mid;
}
}
return lo;
}