Merge sort, quick sort and inversion counter algorithms