public static void ReportDistributiveSort(int n) {
    if (sortingThread != null && sortingThread.isAlive()) return;
    int bas = 10;
    if (n != 3 && !(n >= 5))
      if (n != 4)
        try {
          bas = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter Base for Sort"));
        } catch (Exception e) {
        }
      else
        try {
          bas = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter Size of Partitions"));
        } catch (Exception e) {
        }

    final int base = Math.max(bas, 2);
    final int num = n;
    SetSound(true);
    sortingThread =
        new Thread() {
          @Override
          public void run() {
            try {
              refresharray();
              heading = DistributiveSorts[num] + " Sort";
              switch (num) {
                case 0:
                  radixLSDsort(base);
                  break;
                case 1:
                  radixMSDSort(base);
                  break;
                case 2:
                  RadixLSDInPlace.inPlaceRadixLSDSort(base);
                  break;
                case 3:
                  gravitySort();
                  break;
                case 4:
                  shatterSort(base);
                  break;
              }
            } catch (Exception e) {
            }
            SetSound(false);
          }
        };
    sortingThread.start();
  }
 public static void shuffle(int[] array) {
   for (int i = 0; i < array.length; i++) {
     swap(array, i, (int) (Math.random() * array.length));
     if (SHUFFLEANIM) sleep(1);
   }
 }
 public static int getDigit(int a, int power, int radix) {
   return (int) (a / Math.pow(radix, power)) % radix;
 }