Replaced broken Atd_tsort with new Atd_sort.