refactor dependency sort