bash-3.2$ cat Monday.java
import java.util.*;

class Utilities {
  public static void sort(int[] a, Examiner g) {
    boolean sorted = true;
    for (int i = 0; i < a.length - 1; i = i + 1) {
      if (g.compare(a[i], a[i+1]) > 0) {
        int temp = a[i];
        a[i] = a[i+1];
        a[i+1] = temp;
        sorted = false;
      }
    }
    if (! sorted)
      Utilities.sort(a, g);
  }
}

interface Examiner {
  public int compare(int a, int b);
}

class One implements Examiner {
  public int compare(int a, int b) {
    return a - b;
  }
}

class Two implements Examiner {
  public int compare(int a, int b) {
    return b - a;
  }
}

class Three implements Examiner {
  public int compare(int a, int b) {
    if (a <= 21 && b >  21) return -1;
    if (a  > 21 && b <= 21) return 1;
    return Math.abs(a - 21) - Math.abs(b - 21);
  }
}

class Example {
  public static void main(String[] args) {
    int[] a = {5, 3, 6, 2, 7, 1, 4};
    System.out.println(Arrays.toString(a));
    Utilities.sort(a, new One());
    System.out.println(Arrays.toString(a));
    Utilities.sort(a, new Two());
    System.out.println(Arrays.toString(a));
    int[] b = {19, 23, 21, 22, 17, 26, 20};
    System.out.println(Arrays.toString(b));
    Utilities.sort(b, new Three());
    System.out.println(Arrays.toString(b));

  }
}

bash-3.2$ javac Monday.java
bash-3.2$ java Example
[5, 3, 6, 2, 7, 1, 4]
[1, 2, 3, 4, 5, 6, 7]
[7, 6, 5, 4, 3, 2, 1]
[19, 23, 21, 22, 17, 26, 20]
[21, 20, 19, 17, 22, 23, 26]
bash-3.2$