Merge sort and quick sort reference implementations