vendredi 1 juillet 2016

Achieve same sort result in Chrome as other browsers

Chrome shows a different sort result from other browsers - with Firefox and Edge showing the desired result.

How to achieve the same result with Chrome?

I tried, but not working, with:

$(function(){
    var order = $('.files').find('.first','.second').sort(sortMe);
    $('.files').append(order);
    });

    function sortMe(a, b) {
    return a.first < b.second;
    }

The desired result... and the default in Firefox and other browsers is:

<div class="file-container">
     <div class="files">
           <div class="first">content</div>
           <div class="first">content</div>
           <div class="second">content</div>
           <div class="second">content</div>
     </div>
 </div>

Chrome returns

<div class="file-container">
     <div class="files">
           <div class="first">content</div>
           <div class="second">content</div>
           <div class="second">content</div>
           <div class="first">content</div>
     </div>
 </div>

Aucun commentaire:

Enregistrer un commentaire