First pretty blunt approach at dependency sorting.