implemented merge sort, minor refactoring of quicksort