March 2003
Intermediate to advanced
656 pages
39h 30m
English
insort
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.
Read now
Unlock full access