bisect.insort_left()
bisect.insort_left() is a Python function in the Bisect Module category. Inserts x into sorted list a at the leftmost position. The syntax is bisect.insort_left(a, x, lo=0, hi=len(a)). Parameters: a — sorted list, x — value. Returns: None. A typical example: a = [1, 3, 5]
bisect.insort_left(a, 4)
# a = [1, 3, 4, 5]. A close sibling is bisect.bisect_left(), which returns the insertion point for x in sorted list a, keeping leftmost position on ties. A close sibling is bisect.bisect_right(), which returns the insertion point for x, keeping rightmost position on ties. A close sibling is bisect.insort_right(), which inserts x into sorted list a at the rightmost position. More about this category: Array bisection algorithm — bisect_left, insort, bisect_right. Related Bisect Module entries: bisect.bisect_left(), bisect.bisect_right(), bisect.insort_right(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details.