Home >Backend Development >Python Tutorial >An interesting python sorting module: bisect
Today, a colleague talked about a python sorting module bisect. I thought it was quite interesting and wanted to share it with you.构 First look at the structure of the module:
The first five attributes are interested in everyone, you can play out to see the value, so you won't introduce here. 1 to make sure the list of operations are sorted before using the functions of this module.
First look at the insort function:
out out out of the bisect function: E Then look at the bisect_left_rict_richt function. This function will be inserted into the duplicate value, and the position will be inserted:
its corresponding insertion function is insort_Left and insort_richt:
visible to see visible , simply looking at the results, the operation results of the two functions are the same, but in fact the insertion positions are different.