Use sort instead of qsort thus avoiding compiler warning