MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / insort_right

Function insort_right

tools/python-3.11.9-amd64/Lib/bisect.py:4–16  ·  view source on GitHub ↗

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.

(a, x, lo=0, hi=None, *, key=None)

Source from the content-addressed store, hash-verified

2
3
4def insort_right(a, x, lo=0, hi=None, *, key=None):
5 """Insert item x in list a, and keep it sorted assuming a is sorted.
6
7 If x is already in a, insert it to the right of the rightmost x.
8
9 Optional args lo (default 0) and hi (default len(a)) bound the
10 slice of a to be searched.
11 """
12 if key is None:
13 lo = bisect_right(a, x, lo, hi)
14 else:
15 lo = bisect_right(a, key(x), lo, hi, key=key)
16 a.insert(lo, x)
17
18
19def bisect_right(a, x, lo=0, hi=None, *, key=None):

Callers

nothing calls this directly

Calls 2

bisect_rightFunction · 0.85
insertMethod · 0.45

Tested by

no test coverage detected