toposort with objects