package lesson1;

public class LSD {

    public static void main(String[] args) {
        SortChecker.Result total = new SortChecker.Result();

        int c = 200;

        for (int i = 0; i < c; i++) {
            SortChecker.Result iteration = SortChecker.MakeIteration(data2 -> {
                LSDSort(data2);
                return null;
            });

            total.Append(iteration);
        }

        double av1 = (double) total.getTimeStandard() / SortChecker.Result.TicksPerSecond() / c;
        System.out.println("Elapsed standard = " + av1);

        double av2 = (double) total.getTimeExternal() / SortChecker.Result.TicksPerSecond() / c;
        System.out.println("Elapsed checked = " + av2);

        System.out.println("Ratio = " + av1 / av2);

        System.out.println("Passed = " + total.isPassed());
    }

    public static void LSDSort(int[] data) {
        int w = 4;
        int BITS_PER_BYTE = 8;
        int r = 1 << 8;
        int mask = 0xFF;

        int n = data.length;
        int[] aux = new int[n];

        for (int d = 0; d < w; d++) {
            int[] count = new int[r + 1];
            for (int i = 0; i < n; i++) {
                int c = (data[i] >> BITS_PER_BYTE * d) & mask;
                count[c + 1]++;
            }

            for (int j = 0; j < r; j++) {
                count[j + 1] += count[j];
            }

            if (d == w - 1) {
                int shift1 = count[r] - count[r / 2];
                int shift2 = count[r / 2];
                for (int j = 0; j < r / 2; j++) {
                    count[j] += shift1;
                }
                for (int j = r / 2; j < r; j++) {
                    count[j] -= shift2;
                }
            }

            for (int i = 0; i < n; i++) {
                int c = (data[i] >> BITS_PER_BYTE * d) & mask;
                aux[count[c]++] = data[i];
            }

            System.arraycopy(aux, 0, data, 0, n);
        }
    }
}
@@ -829,24 +829,69 @@
 ());%0A    %7D%0A%0A
+    private static int%5B%5D aux = new int%5B10%5D;%0A%0A
     public s
@@ -1061,20 +1061,49 @@
        i
-nt%5B%5D
+f (n != aux.length) %7B%0A           
  aux = n
@@ -1112,16 +1112,26 @@
  int%5Bn%5D;
+%0A        %7D
 %0A%0A      

Optimizing performance: avoiding reallocations; Target is to optain the Ratio better than 5. Was 4.5, now 4.97 on my computer