treebuilder: insert sorted

By inserting in the right position, we can keep the vector sorted,
making entry insertion almost twice as fast.

---

This is purely a speed increase, with no changes to any external behaviour, so I think it'd be a good candidate for inclusion before we release v0.21.