# pydoc > bisect

---
type: CommandReference
command: bisect
mode: pydoc
section: 
source: pydoc3
---

## Quick Reference

- `bisect.bisect_left(a, x, lo=0, hi=None, key=None)` — find insertion index for x to maintain sorted order (leftmost)
- `bisect.bisect_right(a, x, lo=0, hi=None, key=None)` — find insertion index for x (rightmost)
- `bisect.insort_left(a, x, lo=0, hi=None, key=None)` — insert x into sorted list a (leftmost)
- `bisect.insort_right(a, x, lo=0, hi=None, key=None)` — insert x into sorted list a (rightmost)

## Name

Bisection algorithms.

## Synopsis

Module `bisect` provides array bisection algorithm to keep lists in sorted order after insertion.

## Options

- `bisect.bisect_left(a, x, lo=0, hi=None, key=None)` — Return the index where to insert item x in list a, assuming a is sorted.  All e in a[:i] have e < x; all e in a[i:] have e >= x.  Insert before leftmost x if already present.  Optional args lo (default 0) and hi (default len(a)) bound the slice of a to be searched.
- `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.  All e in a[:i] have e <= x; all e in a[i:] have e > x.  Insert after rightmost x if already present.  Optional args lo (default 0) and hi (default len(a)) bound the slice of a to be searched.
- `bisect.bisect(a, x, lo=0, hi=None, key=None)` — alias for `bisect_right`.
- `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.  If x is already in a, insert it to the left of the leftmost x.  Optional args lo (default 0) and hi (default len(a)) bound the slice of a to be searched.
- `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.  If x is already in a, insert it to the right of the rightmost x.  Optional args lo (default 0) and hi (default len(a)) bound the slice of a to be searched.
- `bisect.insort(a, x, lo=0, hi=None, key=None)` — alias for `insort_right`.

## Examples

No examples provided in the original documentation.

## See Also

- [Python bisect module documentation](https://docs.python.org/3.10/library/bisect.html)