Find total inversions using merge-sort