Compute the number of inversion when sorting an array