Sort the subarray from arr [ l ] to arr [ r ] . sort ( arr , l , r + 1 ) ;
var i , j ; for ( i = l ; i < r + 1 + 1 ; i ++ ) { for ( j = l ; j < r - i + 1 ; j ++ ) { if ( arr [ j ] > arr [ j + 1 ] ) { swap ( arr , j , j + 1 ) ; } } }