tree: Add initial sorting

Signed-off-by: Michael Buesch <m@bues.ch>