0

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('&#9660');
            return (compA < compB) ? 1 : 0;
        } else {
            icon.html('&#9650;');
            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.

twernt
  • 19,803
  • 5
  • 32
  • 41

1 Answers1

0

This question has been resolved before on stack overflow. Take a look at jQuery Function Doesn't Work on Safari.

Community
  • 1
  • 1
Chris Rutherfurd
  • 1,599
  • 1
  • 14
  • 30