Count the number of 'swap' operations needed to sort an integer array.