Sort threaded messages
Write code for sorting a forest of threaded messages:
- Roots in timestamp order
- Children below their parents
- Siblings in timestamp order
The input will be an unsorted collection of messages with parent pointers. The code must not use more than O(n log n) time or space. Algorithms presumably exist already, find them!
Subtask of #122 (closed).