On this page
  1. bisect.insort_left
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

bisect.insort_left

Prev: bisect.insort | Up: bisect | Next: bisect.insort_right
Rel: bisect.bisect, bisect.bisect_left, bisect.bisect_right, bisect.insort
Ref: docs.python.org — bisect.insort_left
Tags: #public #python3 #stdlib #bisect


Import

import bisect
from bisect import insort_left

Signature & Overview

bisect.insort_left(a, x, lo=0, hi=None, *, key=None)

Insert item x in list a, and keep it sorted assuming a is sorted.

Usage

import bisect

arr = [1, 2, 3]
bisect.insort_left(arr, 2)
assert arr == [1, 2, 2, 3]

Gotchas

REPL Inspect

from bisect import insort_left
help(insort_left)

Linked from

Related notes