@@ -0,0 +1,1700 @@
+import java.util.Arrays;%0A%0A/**%0A * Created by aubdira on 10/30/17. CycleSort%0A */%0Apublic class CycleSort %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A        int%5B%5D arr = %7B233, 51, 63, 7, 18, 30, 66, -5, 128, 65, 49, 4%7D;%0A%0A        System.out.println(Arrays.toString(arr));%0A%0A        cycleSort(arr);%0A        System.out.println(Arrays.toString(arr));%0A    %7D%0A%0A    private static void cycleSort(int%5B%5D a) %7B%0A%0A        for (int cycleStart = 0; cycleStart %3C a.length - 1; cycleStart++) %7B%0A            int val = a%5BcycleStart%5D;%0A%0A            // count the number of values that are smaller than val%0A            // since cycleStart%0A            int pos = cycleStart;%0A            for (int i = cycleStart + 1; i %3C a.length; i++) %7B%0A                if (a%5Bi%5D %3C val) %7B%0A                    pos++;%0A                %7D%0A            %7D%0A%0A            // if there aren't any%0A            if (pos == cycleStart) %7B%0A                continue;%0A            %7D%0A%0A            // skip duplicates%0A            while (val == a%5Bpos%5D) %7B%0A                pos++;%0A            %7D%0A%0A            // put val into final position%0A            int tmp = a%5Bpos%5D;%0A            a%5Bpos%5D = val;%0A            val = tmp;%0A%0A            // repeat as long as we can find values to swap%0A            // otherwise start new cycle%0A            while (pos != cycleStart) %7B%0A                pos = cycleStart;%0A                for (int i = cycleStart + 1; i %3C a.length; i++) %7B%0A                    if (a%5Bi%5D %3C val) %7B%0A                        pos++;%0A                    %7D%0A                %7D%0A%0A                while (val == a%5Bpos%5D) %7B%0A                    pos++;%0A                %7D%0A%0A                tmp = a%5Bpos%5D;%0A                a%5Bpos%5D = val;%0A                val = tmp;%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

Add CycleSort.java