How do I modify my code so that it sorts by both data-status and then data-order? ie the desired result is 1,2,3,4
I need to support IE.
You can add any additional criteria in to the sort directly by checking if the fist criteria result == 0 - then check the second, etc
Updated snippet:
$(document.body).on('click', "#sortthem", function(){
var divList = $(".sortme");
divList.sort(function(a, b){
var sort1 = $(a).data("status")-$(b).data("status");
if (sort1 !== 0) return sort1;
var sort2 = $(a).data("order")-$(b).data("order")
return sort2;
});
$("#mydivs").html(divList);
});
4
3
2
1
Sort them