human
Sort a Rotated Sorted Array | Function to restore the Original Sort.
In reverse ( ) , the first parameter is iterator to beginning element and second parameter is iterator to last element plus one ..
Function to print the Array.
Driver code"
How can the above be solved in Python?
 Write me a code to sort a Rotated Sorted Array and the other steps required?
assistant
#Here is code to sort a Rotated Sorted Array and the other steps required.
 def restoreSortedArray ( arr , n ) :
	for i in range ( n ) :
		if ( arr [ i ] > arr [ i + 1 ] ) :
			reverse ( arr , 0 , i ) ;
			reverse ( arr , i + 1 , n ) ;
			reverse ( arr , 0 , n ) ;
def reverse ( arr , i , j ) :
	while ( i < j ) :
		temp = arr [ i ] ;
		arr [ i ] = arr [ j ] ;
		arr [ j ] = temp ;
		i += 1 ;
		j -= 1 ;
def printArray ( arr , size ) :
	for i in range ( size ) :
		print ( arr [ i ] , end = " " ) ;
if __name__ == ' _ _ main _ _ ' :
	arr = [ 3 , 4 , 5 , 1 , 2 ] ;
	n = len ( arr ) ;
	restoreSortedArray ( arr , n - 1 ) ;
	printArray ( arr , n ) ;