Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to sort out elements in vector objects

 
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