Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <meta http-equiv="content-type" content="text/html;charset=Windows-1252">
- <script type="text/javascript">
- var people, asc1 = 1,
- asc2 = 1,
- asc3 = 1,
- asc4 = 1,
- asc5 = 1,
- asc6 = 1,
- asc7 = 1,
- asc8 = 1,
- asc9 = 1,
- asc10 = 1,
- asc11 = 1,
- asc12 = 1;
- window.onload = function () {
- people = document.getElementById("people");
- }
- function sort_table(tbody, col, asc)
- {
- var rows = tbody.rows;
- var rlen = rows.length;
- var arr = new Array();
- var i, j, cells, clen;
- // fill the array with values from the table
- for(i = 0; i < rlen; i++)
- {
- cells = rows[i].cells;
- clen = cells.length;
- arr[i] = new Array();
- for(j = 0; j < clen; j++) { arr[i][j] = cells[j].innerHTML; }
- }
- // sort the array by the specified column number (col) and order (asc)
- arr.sort(function(a, b)
- {
- var retval=0;
- var fA=parseFloat(a[col]);
- var fB=parseFloat(b[col]);
- if(a[col] != b[col])
- {
- if((fA==a[col]) && (fB==b[col]) ){ retval=( fA > fB ) ? asc :
- -1*asc; } //numerical
- else { retval=(a[col] > b[col]) ? asc : -1*asc;}
- }
- return retval;
- });
- for(var rowidx=0;rowidx<rlen;rowidx++)
- {
- for(var colidx=0;colidx<arr[rowidx].length;colidx++){
- tbody.rows[rowidx].cells[colidx].innerHTML=arr[rowidx][colidx]; }
- }
- }
- </script>
Add Comment
Please, Sign In to add comment