How should this code be altered to correctly order / sort numerically and alphabetically? This solution doesn't work for more than 100 items.
http://jsfiddle.net/C2heg/5329/
var $divs = $("div.box");
$('#alphBnt').on('click', function () {
var alphabeticallyOrderedDivs = $divs.sort(function (a, b) {
return $(a).find("h1").text() > $(b).find("h1").text();
});
$("#container").html(alphabeticallyOrderedDivs);
});
$('#numBnt').on('click', function () {
var numericallyOrderedDivs = $divs.sort(function (a, b) {
return $(a).find("h2").text() > $(b).find("h2").text();
});
$("#container").html(numericallyOrderedDivs);
});
The only workable solution I can implement so far is to give all items a three-digit number, e.g. 001, but this not pretty. globalhungerindex.org/countries.html