Return to Snippet

Revision: 26306
at April 23, 2010 03:45 by smashu


Initial Code
var mylist = $('ul');
var listitems = mylist.children('li').get();
listitems.sort(function(a, b) {
   var compA = $(a).text().toUpperCase();
   var compB = $(b).text().toUpperCase();
   return (compA < compB) ? -1 : (compA > compB) ? 1 : 0;
})
$.each(listitems, function(idx, itm) { mylist.append(itm); });

Initial URL

                                

Initial Description

                                

Initial Title
Jquery sort list alphabetically

Initial Tags
sort, list, jquery

Initial Language
JavaScript