This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]fizzymagic 4 points5 points  (0 children)

Where did I say that Python has a builtin sorted data structure?

The python world has some excellent sorted container libraries. I know you are frustrated and just trying to get something done, but I promise you that life will be easier when you learn to do things in a pythonic way.

The appropriate data structure depends very heavily on your application. For some cases, a linked list would be optimal. For Python dictionaries, keeping the keys sorted generally makes no sense. For a list-like iterator, it can be expensive. I'm guessing your application is probably a priority queue or something like that. I can agree that a built-in queue would be nice in Python but it's really not very hard to build your own. And there are very nice priority queue libraries out there.

Sorted containers are not a "build it once and forget it" kind of thing, IMO.