• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sorting line items in a ShoppingCart

 
Jerson Chua
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic