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.

Either you do this

or this, if you do not need a new Vector object created

Related Posts Plugin for WordPress, Blogger...