simple tsort without support for cycles

Signed-off-by: Mattias Andrée <maandree@operamail.com>