merge sort and helper functions