human
Sum of Manhattan distances between all pairs of points | Return the sum of distance of one axis ..
sorting the array ..
for each point , finding the distance ..
Driven Code"
How can the above be solved in Python?

Give me a code to sum of Manhattan distances between all pairs of points and the other steps required?
assistant
#Here is code to sum of Manhattan distances between all pairs of points and the other steps required.
 def distancesum ( arr , n ) :
	arr . sort ( )
	res = 0
	sum = 0
	for i in range ( n ) :
		res += ( arr [ i ] * i - sum )
		sum += arr [ i ]
	return res
def totaldistancesum ( x , y , n ) :
	return distancesum ( x , n ) + distancesum ( y , n )
x = [ - 1 , 1 , 3 , 2 ]
y = [ 5 , 6 , 5 , 3 ]
n = len ( x )
print ( totaldistancesum ( x , y , n ) )