I\'m creating a class where one of the methods inserts a new item into the sorted list. The item is inserted in the corrected (sorted) position in the sorted list. I\'m not
Use the insort function of the bisect module:
import bisect a = [1, 2, 4, 5] bisect.insort(a, 3) print(a)
Output
[1, 2, 3, 4, 5]