Sort 3 numbers | Python3 program to sort an array of size 3 ; Insert arr [ 1 ] ; Insert arr [ 2 ] ; Driver code
def sort3 ( arr ) : NEW_LINE INDENT if ( arr [ 1 ] < arr [ 0 ] ) : NEW_LINE INDENT arr [ 0 ] , arr [ 1 ] = arr [ 1 ] , arr [ 0 ] NEW_LINE DEDENT if ( arr [ 2 ] < arr [ 1 ] ) : NEW_LINE INDENT arr [ 1 ] , arr [ 2 ] = arr [ 2 ] , arr [ 1 ] NEW_LINE if ( arr [ 1 ] < arr [ 0 ] ) : NEW_LINE INDENT arr [ 1 ] , arr [ 0 ] = arr [ 0 ] , arr [ 1 ] NEW_LINE DEDENT DEDENT DEDENT a = [ 10 , 12 , 5 ] NEW_LINE sort3 ( a ) NEW_LINE for i in range ( 3 ) : NEW_LINE INDENT print ( a [ i ] , end = " ▁ " ) NEW_LINE DEDENT