• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to sort the order

 
devaraj nara
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65126
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15452
42
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic