Programmings›Algorithm Cookbook›Chapter 6. Sorting6.20 Inversion CountingCount pairs of elements in the wrong relative order to measure how far an array is from sorted, using a modified merge sort in O(n log n) time.