I tried using the code, as suggested by Eric, but it doesn't work. In my case, I'm trying to sort a bunch of divs based on the value of a span inside each. However, the sorting is completely random!
I don't know what I'm doing wrong! jQuery.noConflict(); $j = jQuery; riggit = { /*...*/ init: function() { //jQuery extensions jQuery.fn.sort = function() { return this.pushStack( jQuery.makeArray( [].sort.apply( this, arguments )) ); }; this.sortByScore($j('#post-0001')); //Sample div id; One among the sortable posts .... }, sortByScore: function(elem) { elem.siblings().sort( function(a,b) { if($j(a).find('.riggit-pointsDisplay').html() == null || $j(b).find('.riggit-pointsDisplay').html() == null) { return 1; } return (parseInt(($j(a).find('.riggit-pointsDisplay').html())) > parseInt($j(b).find('.riggit-pointsDisplay').html())) ? 1 : -1; }).appendTo(elem.parent()); }, }; $j(document).ready(function() { riggit.init(); }); Would be most grateful for any help... Regards, Chinmay bmckenzie wrote: > > Thanks Eric. > > Erik Beeson said the following on 3/26/2007 9:47 AM: >> Even easier than that: >> >> jQuery.fn.sort = function() { >> return this.pushStack( jQuery.makeArray( [].sort.apply( this, >> arguments )) ); >> }; >> >> See here: http://dev.jquery.com/ticket/255 >> >> Looks like I'm still about the only person that actually uses this. >> > I'll probably use it quite a lot. My current app is where I've got a > bunch of forms that I want to rearrange themselves when a person submits > one with a changed date field. Doesn't seem that exotic to me :-) > > Bruce > > -- > Bruce McKenzie > http://www.2MinuteExplainer.com > > _______________________________________________ > jQuery mailing list > discuss@jquery.com > http://jquery.com/discuss/ > > -- View this message in context: http://www.nabble.com/Sorting-items-in-jQuery-pseudo-array-tf3466978.html#a9690202 Sent from the JQuery mailing list archive at Nabble.com. _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/