jQuery's sort() is working when I test in other browsers (Firefox, Opera, Chrome, IE), but fails when I test in Safari.
Is there anything wrong with my code below, or are there things I'm forgetting to make it work in Safari?
var sortConstruídos = false;
$("#m2_construídos").click(function () {
var listitems = $('.villa').get();
var icon = $(this).find('.icon');
listitems.sort(function (a, b) {
var compA = parseInt($(a).find('.m2_construídos').html());
var compB = parseInt($(b).find('.m2_construídos').html());
sortConstruídos = !sortConstruídos;
if (sortConstruídos) {
icon.html('▼');
return (compA < compB) ? 1 : 0;
} else {
icon.html('▲');
return (compA > compB) ? 1 : 0;
}
});
$.each(listitems, function (idx, itm) {
$('.wrap').append(itm);
});
});
I've searched for other answers, but they came with no solution to my problem.