Reputation: 155
We have such method for array
Arrays.sort(Object[] a, int fromIndex, int toIndex);
but to sort a Vector there is only a method using comparator
Vector.sort(Comparator c)
is there any way to sort a vector but using only fromIndex and toIndex?
Upvotes: 0
Views: 46
Reputation: 1265
First of all, Vector
isn't used that much. Use ArrayList
. But to sort a Vector
, use this:
Collections.sort(myVector.subList(startIndex, endIndex));
It will change the original Vector
too.
Upvotes: 1