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


Print Friendly, PDF & Email
Get Sublist from Vector
Iterate over a vector using Enumeration
Shekhar Sharma

Shekhar Sharma

Shekhar Sharma is founder of He is an automation engineer having more than 8 years of experience who loves troubleshooting in automation and finding innovative ways to solve the problems. His other leisurely activities includes playing harmonica, paintings, sketching portrait, watching movies and travelling etc.

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 *