On this page
bisect.insort_right
Prev: bisect.insort_left | Up: bisect
Rel: bisect.bisect, bisect.bisect_left, bisect.bisect_right, bisect.insort
Ref: docs.python.org — bisect.insort_right
Tags: #public #python3 #stdlib #bisect
Import
import bisect
from bisect import insort_right
Signature & Overview
bisect.insort_right(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_right(arr, 2)
assert arr == [1, 2, 2, 3]
Gotchas
- Inserts after existing equal items: Alias of
bisect.insort().
REPL Inspect
from bisect import insort_right
help(insort_right)
Linked from
Related notes
- tuts/python3/stdlib_module/bisect/insort_left Linked here; links to this page; shared tags: #bisect, #stdlib
- tuts/python3/stdlib_module/bisect/bisect Linked here; shared tags: #bisect, #stdlib
- tuts/python3/stdlib_module/bisect/bisect_left Linked here; shared tags: #bisect, #stdlib
- tuts/python3/stdlib_module/bisect/bisect_right Linked here; shared tags: #bisect, #stdlib
- tuts/python3/stdlib_module/bisect/insort Linked here; shared tags: #bisect, #stdlib
- tuts/python3/stdlib_module/bisect links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib
- tuts/c/stdlib/assert/static_assert shared tags: #stdlib