Name
insort
Synopsis
insort(seq
,item
,lo
=0,hi
=sys.maxint)
Like
seq
.insert(bisect(
seq
,item
)
,item
)
.
In other words, seq
must be a sorted
mutable sequence, and insort
modifies
seq
by inserting
item
at the right spot, so that
seq
remains sorted. You may pass optional
arguments lo
and
hi
to operate on the slice
seq
[
lo
:hi
]
.
Module bisect
also supplies functions
bisect_left
, bisect_right
,
insort_left
, and insort_right
for explicit control of search and insertion strategies into
sequences that contain duplicates. bisect
is a
synonym for bisect_right
, and
insort
is a synonym for
insort_right
.
Get Python in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.