human
Sort a stream of integers | Function to sort a stream of integers.
Stores the position of array elements.
Traverse through the array.
If any element is found to be greater than the current element.
If an element > num is not present.
Otherwise , place the number at its right position.
Function to print the sorted stream of integers.
Stores the sorted stream of integers.
Traverse the array.
Function Call.
Print the array after every insertion.
Driver Code"
How can the above be solved in Python?

=====
Write me a code to sort a stream of integers and the other steps required?
assistant
#Here is code to sort a stream of integers and the other steps required.
 def Sort ( ans , num ) :
	pos = - 1 ;
	for i in range ( len ( ans ) ) :
		if ( ans [ i ] >= num ) :
			pos = i ;
			break ;
	if ( pos == - 1 ) :
		ans . append ( num ) ;
	else :
		ans . insert ( pos , num ) ;
	return ans ;
def sortStream ( arr , N ) :
	ans = list ( ) ;
	for i in range ( N ) :
		ans = Sort ( ans , arr [ i ] ) ;
		for j in range ( len ( ans ) ) :
			print ( ans [ j ] , end = " ▁ " ) ;
		print ( ) ;
if __name__ == ' _ _ main _ _ ' :
	arr = [ 4 , 1 , 7 , 6 , 2 ] ;
	N = len ( arr ) ;
	sortStream ( arr , N ) ;