Results 1 to 2 of 2
- 02-04-2012, 08:11 PM #1Member
- Join Date
- Feb 2012
- Rep Power
Question about sorting in ArrayList
Lets say I have an ArrayList of books that holds some data about a few book's title, author and page count, and I want to ask the user if they want to sort by Title or Author or Page Count, is it possible to sort by using ArrayList or should I use simple Array? Because Title and Author will be sorting by String and Page Count will be sorting by integer, i just don't know if ArrayList can do that kind of sorting, i hope my question is understandable...
Re: Question about sorting in ArrayList
Look at the java.util.Collections class API and you'll find some sort methods that work well on ArrayLists. You'll likely need to use some Comparators to allow you to sort on different fields.
- By Chinnu55 in forum Advanced JavaReplies: 8Last Post: 08-13-2011, 06:02 PM
- By busdude in forum New To JavaReplies: 4Last Post: 02-07-2011, 11:48 AM
- By Eranga in forum Java TutorialReplies: 0Last Post: 10-19-2010, 04:43 AM
- By drymsza1234 in forum New To JavaReplies: 2Last Post: 04-15-2010, 01:22 AM
- By flesh-bound-book in forum New To JavaReplies: 3Last Post: 02-13-2010, 12:20 PM