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?
Printable View
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.
That will require the OP to use his own code to set the order.Quote:
Strings beginning with "blablabla" to be shown first