human
Write me a code to replace each element of Array with it 's corresponding rank and the other steps required given the following:
Replace each element of Array with it 's corresponding rank | Function to assign rank to array elements.
Copy input array into newArray.
Sort newArray [ ] in ascending order.
Dictionary to store the rank of the array element.
Update rank of element.
Assign ranks to elements.
Driver Code.
Given array arr [ ].
Function call.
Print the array elements"
Solution in Python:
assistant
#Here is code to replace each element of Array with it 's corresponding rank and the other steps required.
 def changeArr ( input1 ) :
	newArray = input1 . copy ( )
	newArray . sort ( )
	ranks = { }
	rank = 1
	for index in range ( len ( newArray ) ) :
		element = newArray [ index ] ;
		if element not in ranks :
			ranks [ element ] = rank
			rank += 1
	for index in range ( len ( input1 ) ) :
		element = input1 [ index ]
		input1 [ index ] = ranks [ input1 [ index ] ]
if __name__ == " _ _ main _ _ " :
	arr = [ 100 , 2 , 70 , 2 ]
	changeArr ( arr )
	print ( arr )