Open this example in the interactive library
Source code
from bisect import insort
priorities = [1, 3, 9]
insort(priorities, 5)
print(priorities)Sample output
[1, 3, 5, 9]

Open this example in the interactive library
from bisect import insort
priorities = [1, 3, 9]
insort(priorities, 5)
print(priorities)[1, 3, 5, 9]