Professional JavaScript for Web Developers by Nicholas C. Zakas
ISBN: 978-0-7645-7908-0 April 2005
http://www.nczonline.net/ For purchase: http://www.amazon.com/Professional-JavaScript-Developers-Wrox-Guides/dp/0764579088 For publisher website: http://www.wrox.com/WileyCDA/WroxTitle/productCd-0764579088.html --> <html> <head> <title>Table Sort Example</title> <script type="text/javascript">
function convert(sValue, sDataType) { switch(sDataType) { case "int": return parseInt(sValue); case "float": return parseFloat(sValue); case "date": return new Date(Date.parse(sValue)); default: return sValue.toString();
} }
function generateCompareTRs(iCol, sDataType) {
return function compareTRs(oTR1, oTR2) { var vValue1, vValue2;
function sortTable(sTableID, iCol, sDataType) { var oTable = document.getElementById(sTableID); var oTBody = oTable.tBodies[0]; var colDataRows = oTBody.rows; var aTRs = new Array;
for (var i=0; i < colDataRows.length; i++) { aTRs[i] = colDataRows[i]; }