Sorting, Generically

Now that swap and indexOfMin are generic, selectionSort needs almost no change. It relies on indexOfMin, which needs its elements to be comparable, so selectionSort carries the same bound:

public static <T extends Comparable<T>> void selectionSort(DynamicArray<T> a) {
  for (int i = 0; i < a.size() - 1; i++) {
    int min = indexOfMin(a, i);
    swap(a, i, min);
  }
}

The logic is identical to what it was before. Only the signature changed.

One method sorts any comparable type

We can sort the roster with it:

ArrayUtils.selectionSort(roster);  // Students, ordered by ID (their natural order)

The same method also sorts a DynamicArray<Integer> or a DynamicArray<String>, because Integer and String implement Comparable too. We wrote selectionSort once and it sorts every DynamicArray with a comparable type.

Sorting is locked to the natural order

selectionSort orders elements by their natural order, whatever compareTo says, and there is no way to ask it for anything else. Our roster comes out by ID.

A roster has more than one sensible order, though. The registrar might want it ordered by GPA. A printed class list might want it alphabetical by name. We cannot get either one from this selectionSort, and we cannot get it from Student either, since a type has one compareTo and ours is already used for ID. The order has to come from somewhere outside the type.