Title: Message
$(document).ready(
 /* define the jQuery page constructor */
 function() {
  // store a list of all the existing leases per row
  var rows = [];
  // for each form with the id of "frm_existingLeases" get the list of divs with the class "row" that are the children of the div with the level2ID class
  // and store the information into the rows array defined above.
  $("#frm_existingLeases div.level2ID div.row").each(function(){
   // store the text inside the link and the row in the next index of the rows array
   rows[rows.length] = [$(this).find("span.fieldValue a").html().toLowerCase(),this];
  });
  // tell the rows array to sort itself with the following function definition
  rows.sort(
   function(a,b){
    // sort on the text inside the link (existing lease title)
    if (a[0] < b[0]) {
     return -1
    } else if (a[0] > b[0]) {
     return 1
    } else {
     return 0;
    }
   }
  );
  // update the page to display the sortted information correctly.
  $.each(rows,
   function() {
    this[1].parentNode.appendChild(this[1]);
   }
  );
 }
);
 
 

Adrian Sweeney
Web Developer
Mills & Reeve
Tel: +44(0)121 456 8236
[EMAIL PROTECTED]
http://www.mills-reeve.com

-----Original Message-----
From: Erik Beeson [mailto:[EMAIL PROTECTED]
Sent: 19 October 2006 23:32
To: jQuery Discussion.
Subject: [jQuery] Sorting (not tables)

Hello all,

I've been using jQuery for a month or so now and am really enjoying it!

I haven't been able to figure out how to sort a collection of elements. I have something like the following:

<div class="entry"><span class="foo">foo1</span><span class="bar">bar1</span></div
<div class="entry"><span class="foo">foo2</span><span class="bar">bar2</span></div

I would like to be able to do something like:

$('.entry').sort(function(a, b) { return $('.foo', a).text()-$('.foo', b).text(); }).appendTo('#sortedStuff');

Or something like that. I know _javascript_ has a sort function, but that's for arrays, so I'm not sure how that will work with jQuery? Also, a google search for 'jquery sort' (no quotes), brings up some stuff about sorting in the jQuery code, but it appears old and I can't find anything about sorting in the latest release.

Lastly, jQarray.js seems like it would do what I want, but it appears that site is gone (taking jXs with it, btw). It would be nice if plugins were cached on the jQuery site. Anybody have jQarray/jXs?

Thanks,
Erik


Birmingham Law Society 'Law Firm of the Year' 2006
____________________________________________________________________

Mills & Reeve - one of The Sunday Times 100 Best Companies To Work For in 2004, 2005 and 2006

This email is confidential and may be privileged. If you are not the intended recipient please accept our apologies; please do not disclose, copy, or distribute information in this email nor take any action in reliance on its contents: to do so is strictly prohibited and may be unlawful. Please inform us that this message has gone astray before deleting it. Thank you for your co-operation.

Mills & Reeve Solicitors, offices at:

Birmingham: 78-84 Colmore Row, Birmingham, B3 2AB.
Cambridge: Francis House, 112 Hills Road, Cambridge CB2 1PH.
Norwich: 1 St James Court, Whitefriars, Norwich NR3 1RU.
London: Fountain House, 130 Fenchurch Street, London, EC3M 5DJ.

Mills & Reeve is regulated by the Law Society.

A list of Partners may be inspected at any of the above addresses.

Visit our web site at: http://www.mills-reeve.com

This message has been checked for viruses by the Mills & Reeve screening system.

Service cannot be effected on us by e mail.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to