Add sorting ability to jQuery
October 28th, 2008
Self-explanatory
jQuery.fn.sort = function() {
return this.pushStack( jQuery.makeArray( [].sort.apply( this, arguments ) ) );
};
See here for an explanation on custom sorting in JavaScript.
Ninja! And I thought I wrote terse code…
Just wondering whether you need the literal array in there…
Array.prototype.sort? I’m rusty so couldn’t quite follow the scoping of the nested this keyword.
It’s a while, but I seem to recall it wouldn’t work without the literal array. Feel free to play?