Output TOC and tree in sorted order

Fixes #49