Home >Backend Development >Python Tutorial >An interesting python sorting module: bisect

An interesting python sorting module: bisect

高洛峰
高洛峰Original
2016-12-14 15:31:241561browse

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:

An interesting python sorting module: bisect

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.

An interesting python sorting module: bisect                                                                                                                                                                                                                                          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: An interesting python sorting module: bisect

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.

An interesting python sorting module: bisect

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn