Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // --- BEGIN MOD TO STANDARD ---
- // Applies to global.js
- // To sort the apps list
- // By Chti Xof, May 2015
- // adapted from http://stackoverflow.com/questions/8837191/sort-an-html-list-with-javascript#8837300
- var ul=document.querySelector("#apps .listing-apps");
- var new_ul = ul.cloneNode(false);
- // Add all lis to an array
- var lis = [];
- for(var i = ul.childNodes.length; i--;){
- if(ul.childNodes[i].nodeName === 'LI')
- lis.push(ul.childNodes[i]);
- }
- // Sort in ascending order
- lis.sort(function(a, b){
- return a.querySelectorAll("span")[1].innerHTML.localeCompare(b.querySelectorAll("span")[1].innerHTML);
- });
- // Add them into the ul in order
- for(var i = 0; i < lis.length; i++)
- new_ul.appendChild(lis[i]);
- ul.parentNode.replaceChild(new_ul, ul);
- // --- END MOD TO STANDARD
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement