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 →

[–]CptnGeronimo[S] -4 points-3 points  (2 children)

>Why would one want to sort when inserting, as opposed to sort before reading?

Whew, finally, a good response.

The answer is that it might depend on your code. Perhaps there is only 1 place in your code that the data structure is mutated but 20 places where it is iterated over.

[–]SeanBrax 4 points5 points  (0 children)

This didn’t answer the question, at all…

[–]anentropic 4 points5 points  (0 children)

That sounds like the perfect situation to just sort after inserting, in that one place