I want to make different type of sort. I have an ArrayList of Strings. When the information is shown I want all the Strings beginning with "blablabla" to be shown first. How can I achieve that?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
I want to make different type of sort. I have an ArrayList of Strings. When the information is shown I want all the Strings beginning with "blablabla" to be shown first. How can I achieve that?
Look at the Collections class. It has sort methods you can use. You'll need your own code to determine the sort order.
Try to look at Comparator and Comparable interfaces. You have to implement one of these or both interfaces, implement some methods and then sort the method by calling Collections.sort() or something. I can't tell exactly how it goes because I haven't done that for a long time, but the idea should be clear to you. Try to look for some examples with these interfaces.
Last edited by Asido; September 15th, 2010 at 04:33 AM.
That will require the OP to use his own code to set the order.Strings beginning with "blablabla" to be shown first