bisect.insort_right()
bisect.insort_right() is a Python function in the Bisect Module category. Inserts x into sorted list a at the rightmost position. The syntax is bisect.insort_right(a, x, lo=0, hi=len(a)). Returns: None. A typical example: a = [1, 3, 3, 5]
bisect.insort_right(a, 3)
# a = [1, 3, 3, 3, 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_left(), which inserts x into sorted list a at the leftmost 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_left(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details. You can try bisect.insort_right() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.