[jQuery] Re: Is there a jQuery way to sort span-elements?

2009-08-28 Thread Audrey A Lee
hmm... okay. I think I understand this (a little-bit). It reminds me of how I sort objects in an array in Ruby. The way I do that is I need to write a method which compares object-a to object-b. So if each object has attributes like name, address, phone, age, income, I need to decide which

[jQuery] Re: Is there a jQuery way to sort span-elements?

2009-08-28 Thread mkmanning
$.makeArray() converts the elements returned from the jQuery selector to an actual array. Arrays in JavaScript have a sort method, into which you can pass an optional sort function (by default the members of the array are sorted lexicographically). The members of this array are the span elements,

[jQuery] Re: Is there a jQuery way to sort span-elements?

2009-08-27 Thread mkmanning
I'm gonna go out on a limb and assume you want them sorted alphabetically, by span content: var sorted = $.makeArray($('#names span')).sort(function(a,b){ return ($(a).text() $(b).text()) ? -1 : 1; }); $('#names').html(sorted); On Aug 25, 9:14 pm, Audrey Lee audrey.lee.is...@gmail.com wrote:

[jQuery] Re: Is there a jQuery way to sort span-elements?

2009-08-27 Thread jeanph01
Maybe you can take a look at my blog: http://myprogrammingetc.blogspot.com/ The question is : do you want to filter it in a jquery set (in memory) or you want to do it directly on the DOM (in the HTML). On Aug 26, 12:14 am, Audrey Lee audrey.lee.is...@gmail.com wrote: Hello, Assume I have 3