This is what I'm doing to try to sort my <li>
alphabetically, but for some reason, they are not in the correct order. I have a feeling it's because of the entire <li>
tags in the items.push, but I was doing that to preserve the current classes and data attributes that the list item had. Is there a different way I can do this?
var items = [];
$("ul.cat-list li").each(function(){
var liClass = $(this).attr("class");
items.push("<li class="+liClass+" data-task="+$(this).data("task")+">"+$(this).html()+"</li>");
});
items.sort();
$("ul.alpha-list").html(items);