human
Sorting array using Stacks | This function return the sorted stack.
pop out the first element.
while temporary stack is not empty and top of stack is smaller than temp.
pop from temporary stack and append it to the input stack.
append temp in tempory of stack.
append array elements to stack.
Sort the temporary stack.
Put stack elements in arrp [ ].
Driver code"
Solution in Python:
assistant
#Here is code to sorting array using Stacks and the other steps required.
 def sortStack ( input ) :
	tmpStack = [ ]
	while ( len ( input ) > 0 ) :
		tmp = input [ - 1 ]
		input . pop ( )
		while ( len ( tmpStack ) > 0 and tmpStack [ - 1 ] < tmp ) :
			input . append ( tmpStack [ - 1 ] )
			tmpStack . pop ( )
		tmpStack . append ( tmp )
	return tmpStack
def sortArrayUsingStacks ( arr , n ) :
	input = [ ]
	i = 0
	while ( i < n ) :
		input . append ( arr [ i ] )
		i = i + 1
	tmpStack = sortStack ( input )
	i = 0
	while ( i < n ) :
		arr [ i ] = tmpStack [ - 1 ]
		tmpStack . pop ( )
		i = i + 1
	return arr
arr = [ 10 , 5 , 15 , 45 ]
n = len ( arr )
arr = sortArrayUsingStacks ( arr , n )
i = 0
while ( i < n ) :
	print ( arr [ i ] , end = " ▁ " )
	i = i + 1