package algorithms;

public class CountingSort {
    public static void sort(int[] array, int size) {
        int[] aux = new int[array.length];
        for (int i = 0; i < aux.length; i++) {
            aux[i] = array[i];
        }
        int[] count = new int[size];
        for (int i = 0; i < aux.length; i++) {
            count[aux[i]] += 1;
        }
        for (int i = 1; i < count.length; i++) {
            count[i] = count[i - 1] + count[i];
        }
        for (int i = aux.length - 1; i >= 0; i--) {
            int val = aux[i];
            count[val]--;
            int idx = count[val];
            array[idx] = val;
        }
    }
}

@@ -14,16 +14,42 @@
 ithms;%0A%0A
+import java.util.Arrays;%0A%0A
 public c
@@ -365,13 +365,10 @@
 %5Bi%5D%5D
- += 1
+++
 ;%0A  
@@ -445,16 +445,17 @@
 ount%5Bi%5D 
++
 = count%5B
@@ -464,19 +464,8 @@
 - 1%5D
- + count%5Bi%5D
 ;%0A  

Update counting sort