Yep, but my proposal is a constant time (the messages are already ordered) whereas your proposal is at best O(n ln n) (If I rememver correctly my math)... And when we have a lot of messages this is getting important :/

I agree that the best fix would be to use Threads as a model, and always keep a sorted "messages" array (like we do with the DOM messages list currently). If you want to do this now in registerMessage, then ok, we can take this path. But maybe it's best to keep it for a later separate patch. Up to you!