I have this script that I use to sort a list of li's, however it is not working when there is more than one digit, it is sorting with the first digit taking preference, so 10 comes before 2. Is there a way to modify this so it sorts it based on the numeric value?
jQuery.fn.sortDomElements = (function() {
return function(comparator) {
return Array.prototype.sort.call(this, comparator).each(function(i) {
this.parentNode.appendChild(this);
});
};
})();
$("#sortable3, #sortable4").children().sortDomElements(function(a,b){
akey = $(a).attr("sortkey");
bkey = $(b).attr("sortkey");
if (akey == bkey) return 0;
if (akey < bkey) return -1;
if (akey > bkey) return 1;
});