Input
Output
Enter values
This page brought to you by ...
Currently featured sort: insertion sort!
function mySort(na) {
//
// INSERTION SORT ... YEAH!!
//
var n = na.length ;
var i, j ;
for ( i=1; i<n; i++ ) {
for ( j=i; j>0; j-- ) {
if ( na[j]>=na[j-1] ) break ;
t = na[j] ;
na[j] = na[j-1] ;
na[j-1] = t ;
}
}
return na ;
}
Modify the javascript to implement your choice, either:
- mergesort
- heapsort
- quicksort
References
-
Use view source, or use curl
or wget, to get this page.
-
JavaScript
information at mozilla.
- CSC 598
reference section (near bottom).