/** * @example *
* int[] testi = {4, 2, 4, 0}; * jarjesta(testi); * testi[0] === 0; * testi[1] === 2; * testi[2] === 4; * testi[3] === 4; **/ public static void jarjesta(int[] taulukko) { int[] apu = new int[taulukko.length+1]; for (int i = 0; i < taulukko.length; i++) apu[taulukko[i]]++; int j = 0; for (int i = 0; i < apu.length; i++) while (apu[i]-- > 0) taulukko[j++] = i; }