Switch to using qsort and check in main if output is indeed sorted.