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