Today, my colleague talked about a Python sort of module bisect, I think it is very interesting to share with you.
First look at the structure of the module:
The first five properties are interesting to be able to play out to see the value, here is not introduced.
First of all, make sure that the list of actions is sorted before using the function of this module.
First look at the Insort function:
The result of its insertion does not affect the original sort.
And look at the Bisect function:
The purpose is to find where the value will be inserted and return it without inserting it.
Then look at the Bisect_left and Bisect_right functions, where the function will insert a repeating number and return where it will be inserted:
The corresponding insertion functions are insort_left and insort_right:
It can be seen that the results of two functions are the same, but the position of inserting is different.