Stable sort for descending order | javascript program to demonstrate descending order ; Driver code
function reverse ( a ) { var i , k , n = a . length ; var t ; for ( i = 0 ; i < n / 2 ; i ++ ) { t = a [ i ] ; a [ i ] = a [ n - i - 1 ] ; a [ n - i - 1 ] = t ; } } var arr = [ 1 , 5 , 8 , 9 , 6 , 7 , 3 , 4 , 2 , 0 ] ; var n = arr . length ; arr . sort ( ) ; reverse ( arr ) ; document . write ( " " + " " ) ; for ( var i = 0 ; i < n ; ++ i ) { document . write ( arr [ i ] + " " ) ; }