Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to sort out elements in vector objects  RSS feed

 
senthil sen
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to sort out elements in vector objects?
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at Collections.sort(). If the elements implement Comparable then you can just do this:

If not then you can provide a Comparator like this:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!