--------------------------------------- The input word is, [6, 2, 7, 1, 10, 11, 3, 5, 4, 8, 12, 9], of length, 12 its major index is, 29 The last letter is, 9, and the one before it is, 12 The chopped word, after deleting the last letter, 9, is : [6, 2, 7, 1, 10, 11, 3, 5, 4, 8, 12] Its major index is, 18 Applying the Foata bijection recursively (details omitted), we get [6, 2, 7, 1, 10, 3, 11, 5, 4, 8, 12] whose number of inversions is, 18 Since , 9 < 12, we have Case II The break-up where entries smaller or equal than, 9, are lumped together, but entries larger , 9, are by themselves is [[6, 2, 7, 1], [10], [3], [11], [5, 4, 8], [12], []] And after the clever Foata interchange [[10], [6, 2, 7, 1], [11], [3], [12], [5, 4, 8]] Catenating, and appending the last letter, 9, we get [10, 6, 2, 7, 1, 11, 3, 12, 5, 4, 8, 9]