On this page
bisect.bisect_right
Prev: bisect.bisect_left | Up: bisect | Next: bisect.insort
Rel: bisect.bisect, bisect.bisect_left, bisect.insort, bisect.insort_left
Ref: docs.python.org — bisect.bisect_right
Tags: #public #python3 #stdlib #bisect
Import
import bisect
from bisect import bisect_right
Signature & Overview
bisect.bisect_right(a, x, lo=0, hi=None, *, key=None)
Return the index where to insert item x in list a, assuming a is sorted.
Usage
import bisect
arr = [10, 20, 20, 30]
assert bisect.bisect_right(arr, 20) == 3
Gotchas
- Returns the index after any existing equal entries: Great for bucket/threshold lookups (like grade cutoffs).
REPL Inspect
from bisect import bisect_right
help(bisect_right)
Linked from
Related notes
- tuts/python3/stdlib_module/bisect/bisect Linked here; links to this page; shared tags: #bisect, #stdlib
- tuts/python3/stdlib_module/bisect/bisect_left Linked here; links to this page; shared tags: #bisect, #stdlib
- tuts/python3/stdlib_module/bisect/insort Linked here; links to this page; shared tags: #bisect, #stdlib
- tuts/python3/stdlib_module/bisect/insort_left Linked here; links to this page; shared tags: #bisect, #stdlib
- tuts/python3/stdlib_module/bisect/insort_right links to this page; 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