use mergesort. apparently qsort has issues on a mac.