Output TOC and tree in sorted order to make output stable between invocations. Addresses issue #49