Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

jquery sort listing alphabetically

var mylist = $('#myUL');
var listitems = mylist.children('li').get();
listitems.sort(function(a, b) {
   return $(a).text().toUpperCase().localeCompare($(b).text().toUpperCase());
})
$.each(listitems, function(idx, itm) { mylist.append(itm); });
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #jquery #sort #listing #alphabetically
ADD COMMENT
Topic
Name
1+6 =