Fix group uploads by topologically sorting