Saturday, July 17, 2021

How to sort elements of vector object on particular column

Using sort() method on vector object we can sort elements of vector object.
For this purpose we need to create our own comparator.
Steps to follow
1. Create own Comparator class by implementing Comparator interface and define compare method.
2. use vector.sort() method and pass the object of your own Comparator implemented class.
3. finally you vector object will have sorted elements as per your compare() method defined.

Please go through the above video for more in details.


No comments:

Post a Comment