is there anyways to sort a vector into ascending/descending order? im trying to do this for a vector of dates.
posted 10 years ago
A java.util.Vector is a java.util.List, and there are sort methods for Lists in java.util.Collections. Dates are java.lang.Comparable, so "by default" they will be sorted in increasing order, but Collections also has a sort that let lets you supply a java.util.Comparator to determine the ordering. Finally, to reverse the "natural" Comparable ordering, see Collections' reverseOrder method, or use Collection's reverse method to reverse the list itself.