import bisect
a = [1, 2, 4, 5]
bisect.insort(a, 3)
print(a)
import bisect
a = [1, 2, 4, 5]
bisect.insort(a, 3)
print(a)
# list insert bisect Python. insert value in a sorted list.
import bisect
a = [1, 2, 4, 5]
value = 3
bisect.insort(a, value)
print(a)
# [1, 2, 3, 4, 5]
# Alternative implementation
idx = bisect.bisect(a, value)
print(idx)
# 2
a.insert(idx, value)
print(a)
# [1, 2, 3, 4, 5]