Comparators allow you to sort based on however many columns you want.

See the docs for Comparator, from
http://java.sun.com/j2se/1.3/docs/api/index.html for more information. If
you still need help after checking the API, send another email and I'll see
what time I can find to write an example.

>From: Jerson Chua <[EMAIL PROTECTED]>
>Reply-To: A mailing list about Java Server Pages specification and
>     reference <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Sorting line items in a ShoppingCart
>Date: Mon, 12 Feb 2001 18:48:13 +0800
>
>Hi...
>For example, if I have a ShoppingCart object which contains an ArrayList of
>lineItem objects. Each lineitem object contains the attribute productName,
>productPrice, productCode, and quantity.
>
>Here's the expected behavior.
>
>For example... initially it's sorted by
>productCode, productName, productPrice, and quantity.
>
>If the user clicks productName then it will be sorted by
>productName, productCode, productPrice, and quantity.
>
>If the user clicks productPrice then it will be sorted by
>productPrice, productName, productCode, and quantity.
>
>and so on...
>
>Initially I planned to use Comparator but this can only be used for sorting
>a single column.
>
>How do I implement such functionality?
>
>thank you very much your help will be very much appreciated.
>
>Jerson
>
>===========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>JSP-INTEREST".
>For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
>DIGEST".
>Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to