@@ -0,0 +1,2264 @@
+package io.dindinw.algo;%0A%0Aimport static org.junit.Assert.assertArrayEquals;%0A%0Aimport java.util.Arrays;%0Aimport java.util.Collections;%0Aimport java.util.List;%0Aimport java.util.ListIterator;%0A%0Aimport org.junit.Test;%0A/**%0A *  1. Big O Notation .%0A *  O(n%5E2) means that if input is 2 then, algorithm takes 2%5E2 -%3E 4 times longer to run. so it %0A *  means a bad algorithm in most case.%0A *  %0A *  2. DualPivotQuicksort%0A *  A Quicksort algorithm by Vladimir Yaroslavskiy, Jon Bentley, and Josh Bloch.%0A *  @see%0A *  http://permalink.gmane.org/gmane.comp.java.openjdk.core-libs.devel/2628%0A *  http://programmingisterrible.com/post/41512566174/engineering-quicksort%0A *  http://java.dzone.com/articles/algorithm-week-quicksort-three%0A *  https://github.com/arunma/DataStructuresAlgorithms/tree/master/src/basics/sorting/quick%0A *  %0A * @author yidwu%0A *%0A */%0Apublic class SortTest %7B%0A    %0A    /**%0A     * in Arrays.sort() use DualPivotQuicksort%0A     */%0A    @Test%0A    public void sortInts() %7B%0A        final int%5B%5D numbers = %7B-3, -5, 1, 7, 4, -2%7D;%0A        final int%5B%5D expected = %7B-5, -3, -2, 1, 4, 7%7D;%0A        Arrays.sort(numbers);%0A        assertArrayEquals(expected, numbers);%0A    %7D%0A    /**%0A     * Inside the Collections.sort() method, also use Arrays.sort()%0A     *  Object%5B%5D a = list.toArray();%0A        Arrays.sort(a);%0A        ListIterator%3CT%3E i = list.listIterator();%0A        for (int j=0; j%3Ca.length; j++) %7B%0A            i.next();%0A            i.set((T)a%5Bj%5D);%0A        %7D%0A     */%0A    @Test%0A    public void sortIntList() %7B%0A        final String%5B%5D strings = %7B%22z%22, %22x%22, %22y%22, %22abc%22, %22zzz%22, %22zazzy%22%7D;%0A        final String%5B%5D expected = %7B%22abc%22, %22x%22, %22y%22, %22z%22, %22zazzy%22, %22zzz%22%7D;%0A        %0A        List%3CString%3E list = Arrays.asList(strings);%0A        Collections.sort(list);%0A        %0A        ListIterator%3CString%3E i = list.listIterator();%0A        for (int j=0; j%3Cstrings.length; j++)%7B%0A            strings%5Bj%5D = i.next();%0A        %7D%0A        %0A        assertArrayEquals(expected, strings);%0A    %7D%0A    %0A    /**%0A     * %0A     */%0A    @Test%0A    public void sortObjects() %7B%0A        final String%5B%5D strings = %7B%22z%22, %22x%22, %22y%22, %22abc%22, %22zzz%22, %22zazzy%22%7D;%0A        final String%5B%5D expected = %7B%22abc%22, %22x%22, %22y%22, %22z%22, %22zazzy%22, %22zzz%22%7D;%0A        Arrays.sort(strings);%0A        assertArrayEquals(expected, strings);%0A    %7D%0A    %0A%0A    %0A    %0A%0A%7D%0A

add a sort tester for Arrays.sort() and Collections.sort().