support nested dependency sorting.