Sorting the dependencies