package username.sorting; import java.util.Arrays; import java.util.Comparator; /** * Sort using built-in sort operations. */ public class BISorter implements Sorter { public Vector sort(Vector vec, Comparator c) { // There is a built-in sort operation for arrays, so // get the array. T[] arr = (T[]) vec.toArray(); // Use the built-in algorithm. Arrays.sort(arr, 0, arr.length, c); // Convert back to a vector. Vector sorted = new Vector(arr.length); for (int i = 0; i < arr.length; i++) { sorted.add(arr[i]); } // for return sorted; } // sort(Vector, Comparator) } // class BISorter