sort-it-up

Benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

<div class="column">
    <span>1</span>
    <span>2</span>
    <span>3</span>
</div>
<div class="column">
    <span>1</span>
</div>
<div class="column">
    <span>1</span>
    <span>2</span>
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
map
$('.column').map(function() {
 var el = $(this);
 return {
  el: el,
  kids: el.children().length
 };
}).get().sort(function(a, b) {
 return a.kids - b.kids;
}).shift().el.css('color', 'red');
ready
sort
$('.column').sort(function(a, b) {
 return $(a).children().length - $(b).children().length;
}).eq(0).css('color', 'red');
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.