Sort a Vector using Collections.sort()

In the previous post, we have seen how to get the sublist from vector. In this pos, we will see how to sort a vector using Collections.sort().

Vector maintains insertion order in which they are added to the vector. If you want to sort the vector, you can use Collections class.

Let’s understand with the example.



All cars :[BMW, Honda, Audi, Ferrari, Bugatti]
Sorted vector : [Audi, BMW, Bugatti, Ferrari, Honda]

Have any question or suggestion for us?Please feel free to post in Q&A Forum


Get Sublist from Vector
Iterate over a vector using Enumeration
Shekhar Sharma

Shekhar Sharma

Shekhar Sharma is founder of This website is his window to the world. He believes that ,"Knowledge increases by sharing but not by saving".

You may also like...

1 Response

  1. September 20, 2015

    […] the previous post, we have seen how to sort the vector. In this post, we will see how to iterate over a vector using […]

Leave a Reply

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