Javascript program to implement min max selection sort .
function swap ( arr , xp , yp ) { var temp = arr [ xp ] ; arr [ xp ] = arr [ yp ] ; arr [ yp ] = temp ; } function minMaxSelectionSort ( arr , n ) { for ( var i = 0 , j = n - 1 ; i < j ; i ++ , j -- ) { var min = arr [ i ] ; var max = arr [ i ] ; var min_i = i ; var max_i = i ; for ( var k = i ; k <= j ; k ++ ) { if ( arr [ k ] > max ) { max = arr [ k ] ; max_i = k ; } else if ( arr [ k ] < min ) { min = arr [ k ] ; min_i = k ; } }