def sort( x ) ( 0..x.length-2 ).each { |i| ( i..x.length-1 ).each { |j| if x[ i ] > x [ j ] then work = x[ i ] x[ i ] = x[ j ] x[ j ] = work end } } end a = [ 3 , 6 , 2 , 4 , 10 , 7 ] sort( a ) a.length.times { |i| printf( "%d " , a[ i ] ) } printf( "\n" )