function sort_rows() {
    read_rows();
    //alert("sorting the rows of " + preftable);
    var permut = new Array;
    for (var i = 0; i < num_choices; i++) {
        permut[i] = i;
    }
    function compare(m,n) {
        if (rank[m] < rank[n]) return -1;
        if (rank[m] > rank[n]) return 1;
        if (m < n) return -1; // make it stable, please!
        if (m > n) return 1;
        return 0;
    }
    permut.sort(compare);
    diag = "";
    var newselected = new Array;
    for (var i = 0; i < permut.length; i++) {
        var j = permut[i];
        prefsection.appendChild(rows[j]);
        newselected[i] = selected[j];
        diag = diag + j;
    }
    selected = newselected;
    //alert("permutation: " + diag);
    read_rows();
    set_row_borders();
}
// stably sort rows by their rank
stably sort rows by their rank
stably sort rows by their rank
function sort_rows() {
    read_rows();
    var permut = new Array;
    for (var i = 0; i < num_choices; i++) {
        permut[i] = i;
    }
    function compare(m,n) {
        if (rank[m] < rank[n]) return -1;
        if (rank[m] > rank[n]) return 1;
        if (m < n) return -1; 
        if (m > n) return 1;
        return 0;
    }
    permut.sort(compare);
    diag = "";
    var newselected = new Array;
    for (var i = 0; i < permut.length; i++) {
        var j = permut[i];
        prefsection.appendChild(rows[j]);
        newselected[i] = selected[j];
        diag = diag + j;
    }
    selected = newselected;
    read_rows();
    set_row_borders();
}
function sort_rows ( ) { read_rows ( ) ; var permut = new Array ; for ( var i = 0 ; i < num_choices ; i ++ ) { permut [ i ] = i ; } function compare ( m , n ) { if ( rank [ m ] < rank [ n ] ) return - 1 ; if ( rank [ m ] > rank [ n ] ) return 1 ; if ( m < n ) return - 1 ; if ( m > n ) return 1 ; return 0 ; } permut . sort ( compare ) ; diag = "" ; var newselected = new Array ; for ( var i = 0 ; i < permut . length ; i ++ ) { var j = permut [ i ] ; prefsection . appendChild ( rows [ j ] ) ; newselected [ i ] = selected [ j ] ; diag = diag + j ; } selected = newselected ; read_rows ( ) ; set_row_borders ( ) ; }
stably sort rows by their rank
stably sort rows by their rank
//alert("sorting the rows of " + preftable); // make it stable, please! //alert("permutation: " + diag);