Quote from: Sams Teach Yourself JavaScript in 21 Days (Paperback) by Jonathan A. Watt (Author), Andrew H. Watt (Author), Jinjer Simon (Author), Jonathan A Watt (Author)
function sortByFrom(a, b) { var A = a["From"].toLowerCase(); var B = b["From"].toLowerCase(); if (A < B) return -1; if (A > B) return 1; return 0; }
function sortByDate(a, b) { var A = a["Date"]; var B = b["Date"]; if (A < B) return -1; if (A > B) return 1; return 0; }
function sortBySubject(a, b) { var A = a["Subject"].toLowerCase(); var B = b["Subject"].toLowerCase(); if (A < B) return -1; if (A > B) return 1; return 0; }
var sortCriteria = location.search.substr(1);
if (sortCriteria) { emails.sort(eval(sortCriteria)); }