How to use bisect.insort_left with a key?

后端 未结 4 753
时光说笑
时光说笑 2020-12-09 14:34

Doc\'s are lacking an example...How do you use bisect.insort_left)_ based on a key?

Trying to insert based on key.

bisect.insort_left(da         


        
4条回答
  •  时光说笑
    2020-12-09 15:40

    If your goal is to mantain a list sorted by key, performing usual operations like bisect insert, delete and update, I think sortedcontainers should suit your needs as well, and you'll avoid O(n) inserts.

提交回复
热议问题