Create a jQuery object collection from separate jQuery objects


<pre class="lang-js prettyprint-override"><code>$.fn.sortByDepth = function() {
    var ar = [];
    var result = $([]);

    $(this).each(function() {
        ar.push({length: $(this).parents().length, elmt: $(this)});
    });
    ar.sort(function(a,b) {
        return b.length - a.length;
    });
    for (var i=0; i&lt;ar.length; i++) {
        result.add(ar[i].elmt);
    };
    alert(result.length);
    return result;
};
</code></pre>

<p>In this function I try to create a jQuery collection from separate jQuery object. How can i do that ?</p>

<p>The code below doesn't work:</p>

<pre class="lang-js prettyprint-override"><code>result.add(ar[i].elmt);
</code></pre>

<p>The jsfiddle: <a href="http://jsfiddle.net/hze3M/14/" rel="nofollow">http://jsfiddle.net/hze3M/14/</a></p>
