[jQuery] Sorting (not tables)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<TITLE>Message</TITLE>
<META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial color=#0000ff size=2>$(document).ready(<BR> /* define
the jQuery page constructor */<BR> function() {<BR> // store a
list of all the existing leases per row<BR> var rows =
[];<BR> // 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 <BR> // and store the information into the rows array
defined above.<BR> $("#frm_existingLeases div.level2ID
div.row").each(function(){<BR> // store the text inside the
link and the row in the next index of the rows
array<BR> rows[rows.length] = [$(this).find("span.fieldValue
a").html().toLowerCase(),this];<BR> });<BR> // tell the
rows array to sort itself with the following function
definition<BR> rows.sort(<BR> function(a,b){<BR> //
sort on the text inside the link (existing lease
title)<BR> if (a[0] < b[0])
{<BR> return -1<BR> } else
if (a[0] > b[0]) {<BR> return
1<BR> } else {<BR> return
0;<BR> }<BR> }<BR> );<BR> //
update the page to display the sortted information
correctly.<BR> $.each(rows, <BR> function()
{<BR> this[1].parentNode.appendChild(this[1]);<BR> }<BR> );<BR> }<BR>);<BR></FONT></DIV>
<DIV> </DIV>
<DIV> </DIV>
<P><FONT face=Arial size=2><B>Adrian Sweeney</B></FONT> <BR><FONT face=Arial
size=2>Web Developer</FONT> <BR><FONT face=Arial size=2>Mills & Reeve</FONT>
<BR><FONT face=Arial size=2>Tel: +44(0)121 456 8236</FONT> <BR><FONT face=Arial
size=2><A
href="mailto:adrian.sweeney@mills-reeve.com">adrian.sweeney@mills-reeve.com</A></FONT>
<BR><FONT face=Arial size=2><A
href="http://www.mills-reeve.com/">http://www.mills-reeve.com</A></FONT> </P>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px">
<DIV></DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT
face=Tahoma size=2>-----Original Message-----<BR><B>From:</B> Erik Beeson
[mailto:erik.beeson@gmail.com] <BR><B>Sent:</B> 19 October 2006
23:32<BR><B>To:</B> jQuery Discussion.<BR><B>Subject:</B> [jQuery] Sorting
(not tables)<BR><BR></FONT></DIV>Hello all,<BR><BR>I've been using jQuery for
a month or so now and am really enjoying it!<BR><BR>I haven't been able to
figure out how to sort a collection of elements. I have something like the
following:<BR><BR><div class="entry"><span
class="foo">foo1</span><span
class="bar">bar1</span></div <BR><div class="entry"><span
class="foo">foo2</span><span
class="bar">bar2</span></div<BR><BR>I would like to be able to do
something like:<BR><BR>$('.entry').sort(function(a, b) { return $('.foo', a).text()-$('.foo', b).text(); }).appendTo('#sortedStuff');<BR><BR>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. <BR><BR>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?<BR><BR>Thanks, <BR>Erik<BR></BLOCKQUOTE><FONT SIZE=3><BR>
<BR>
<b>Birmingham Law Society 'Law Firm of the Year' 2006</b><BR>
____________________________________________________________________<BR>
<BR>
<b>Mills & Reeve - one of The Sunday Times 100 Best Companies To Work For in 2004, 2005 and 2006</b><BR>
<BR>
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.<BR>
<BR>
Mills & Reeve Solicitors, offices at:<BR>
<BR>
Birmingham: 78-84 Colmore Row, Birmingham, B3 2AB.<BR>
Cambridge: Francis House, 112 Hills Road, Cambridge CB2 1PH. <BR>
Norwich: 1 St James Court, Whitefriars, Norwich NR3 1RU.<BR>
London: Fountain House, 130 Fenchurch Street, London, EC3M 5DJ.<BR>
<BR>
Mills & Reeve is regulated by the Law Society.<BR>
<BR>
A list of Partners may be inspected at any of the above addresses.<BR>
<BR>
Visit our web site at: http://www.mills-reeve.com<BR>
<BR>
This message has been checked for viruses by the Mills & Reeve screening system.<BR>
<BR>
Service cannot be effected on us by e mail.<BR>
</FONT>
</BODY></HTML>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/