Implement step reordering by dependencies