Counting inversions
inversions += ( mid - i + 1 ) NEW_LINE temp [ k ] = v [ j ] NEW_LINE k += 1 NEW_LINE j += 1 NEW_LINE while ( i <= mid ) : NEW_LINE temp [ k ] = v [ i ] NEW_LINE k += 1 NEW_LINE i += 1 NEW_LINE while ( j <= right ) : NEW_LINE temp [ k ] = v [ j ] NEW_LINE k += 1 NEW_LINE j += 1 NEW_LINE k = 0 NEW_LINE for a in range ( left , right + 1 , 1 ) : NEW_LINE v [ a ] = temp [ k ] NEW_LINE k += 1 NEW_LINE