Sort A Vector Using Comparator In Java

If your Vector object contains a set of custom class objects with a property of int and you want it to sort in ascending order, you can do it like this.

The getNumber() method contains the int value that will be used as basis to sort them in ascending order. To sort them in descending order, simply add a – (negative) sign after the keyword return.

Related Posts Plugin for WordPress, Blogger...


  1. Wonderful article, this is very similar to a site that I have. Please check it out sometime and feel free to leave me a comenet on it and tell me what you think. I’m always looking for feedback.

Leave a Reply

Your email address will not be published. Required fields are marked *