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

bisect.insort

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


Import

import bisect
from bisect import insort

Signature & Overview

bisect.insort(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, 3, 5]
bisect.insort(arr, 4)
assert arr == [1, 3, 4, 5]

Gotchas

REPL Inspect

from bisect import insort
help(insort)

Linked from

Related notes