Example:

Enter numbers to sort in this box and then click here.


This was your input:


This is the sorted output:>


This page brought to you by 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 ;
}

Assignment:

Modify the javascript to implement your choice, either:

References