I'd guess it's because arguments isn't really an array (it has a length 
property, but none of 
Array's methods).

Something like this might do the trick:

jQuery.fn.sort = function() {
     for(var i = 0, args = []; i < arguments.length; i++)
         args.push(i);
     return this.pushStack( [].sort.apply( this, args ), []);
};

Luke


Bruce McKenzie wrote:
> There was a thread on this list in October which indicates (if I read it 
> right) that I ought to be able to rearrange some paragraphs as follows:
> 
> <script type="text/javascript">
> 
> $(function(){
> 
>      jQuery.fn.sort = function() {
>        return this.pushStack( [].sort.apply( this, arguments ), []);
>      };
> 
>      $("p.items").sort(function(a,b){
>          return a.innerHTML > b.innerHTML ? 1 : -1;
> 
>      }).appendTo("#Foo");
> 
> });
> </script></head>
> <body>
> 
> <div id='Foo'>
> <p class='items'>C</p>
> <p class='items'>B</p>
> <p class='items'>A</p>
> </div>
> 
> </body>
> </html>
> 
> But this error results:
> error: second argument to Function.prototype.apply must be an array
> 
> Is it me -- or does the sort function need to be adjusted for jQuery 
> 1.1.1 (and how would a person do that :-) ?
> 


-- 
zinc Roe Design
www.zincroe.com
(647) 477-6016

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to