Sorting dependencies