Array.prototype.stableSort = function(cmp) { cmp = !!cmp ? cmp : (a, b) => { if (a < b) return -1; if (a > b) return 1; return 0; }; let stabilizedThis = this.map((el, index) => [el, index]); let stableCmp = (a, b) => { let order = cmp(a[0], b[0]); if (order != 0) return order; return a[1] - b[1]; } stabilizedThis.sort(stableCmp); for (let i=0; i bValue) return 1; return 0; } function orderStringSorter(a,b) { var aValue=a.children[1].innerHTML.substring(0,3); var bValue=b.children[1].innerHTML.substring(0,3); if ( aValue == "[x]" && bValue == "[ ]" ) return 1; if ( aValue == "[ ]" && bValue == "[x]" ) return -1; var aDone = new RegExp("\\(.+\\)$").test(a.children[1].innerHTML); var bDone = new RegExp("\\(.+\\)$").test(b.children[1].innerHTML); if ( aDone && ! bDone ) return 1; if ( bDone && ! aDone ) return -1; return 0; } function scrollBack() { var position=parseInt(get_cookie("position")); window.scrollTo(0,position); } // Close the dropdown menu if the user clicks outside of it window.onclick = function(event) { if (!event.target.matches('.dropbtn')) { dropDownHide(); } } document.onscroll = function(event) { document.cookie = "position=" + window.scrollY + "; path=" + window.location.pathname; } window.onload = scrollBack;