Replace qsort with simple bubble sorting function to reduce code size.