Forums Register Login

how to sort the order

+Pie Number of slices to send: Send
Hi,

I have a collection(vector) containing strings.

String is of the format like : 1~bat~34.

eg: 1~qual~34
29~qual~39
3~pend~89
4~sub~24
5~notqual~28
Now, I want these things in order. It means sub should be first, then qual,then pend, then notqual.
Wanted order is like this : 4~sub~24 then 1~qual~34 then 29~qual~39,then 3~pend~89 then 5~notqual~28. can anyone tell me how to do this.
+Pie Number of slices to send: Send
Please take the time to choose the correct forum for your posts. This forum is for questions on Servlets.

This post has been moved to a more appropriate forum.
+Pie Number of slices to send: Send
You can use the method sort(List, Comparator) in the class java.util.Collections. The first argument to this method is your Vector, the second is a Comparator object that you have to write which determines the sort order.

Look those classes up in the API documentation and write some code. If you get stuck, please post your code here and explain where you get stuck.
It sure was nice of your sister to lend us her car. Let's show our appreciation by sharing this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 486 times.
Similar Threads
Magic Square water retention
Query problem with MySQL 5
100 times "hello world" without loop or recursive
using this recursive method slows me down....why?
Prime numbers
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 08:07:53.