import java.util.*;
    
/**
 * Given a list of non negative integers, arrange them such that they form the
 * largest number.
 * 
 * For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.
 * 
 * Note: The result may be very large, so you need to return a string instead
 * of an integer.
 * 
 * Tags: Sort
 */
class LargestNum {
    public static void main(String[] args) {
        LargestNum ln = new LargestNum();
        int[] num = {3, 30, 34, 5, 9};
        System.out.println(ln.largestNumber(num));
    }
    
    /**
     * Create a comparator for sorting
     * Convert num to String and compare the concatenated result of them
     * Note {0, 0} is a special case
     */
    public String largestNumber(int[] num) {
        StringBuilder res = new StringBuilder();
        if (num == null || num.length == 0) return res.toString();
        String[] str = new String[num.length];
        for (int i = 0; i < num.length; i++) str[i] = num[i] + "";
        Comparator<String> comp = new Comparator<String>() {
            @Override
            public int compare(String s1, String s2) {
                return Long.compare(Long.valueOf(s2 + s1), Long.valueOf(s1 + s2));
            }
        };
        Arrays.sort(str, comp); // acsending order regarding to comp, which prefers the -1 output of comp.
        /*
         * str[0] is the smallest element in order that defined by comp.
         * It implies that  for any i, comp.compare(str[0], str[i]) ==  -1,
         * So str[i] + str[0] is less than str[0] + str[i].
         */
        if (str[0].equals("0")) return "0"; // deal with 0
        for (String s : str) res.append(s);
        return res.toString();
    }
}

@@ -1230,338 +1230,270 @@
     
-Arrays.sort(str, comp); // acsending order regarding to comp, which prefers the -1 output of comp.%0A        /*%0A         * str%5B0%5D is the smallest element in order that defined by comp.%0A         * It implies that  for any i, comp.compare(str%5B0%5D, str%5Bi%5D) ==  -1,%0A         * So str%5Bi%5D + str%5B0%5D is less than str%5B0%5D + str%5Bi%5D.%0A         */
+%0A        /* Bubble sort xxs1s2xxx or xxs2s1xxx%0A         * compare(%223%22,%2230%22) = -1 given 303 %3C 330%0A         * compare(%225%22,%229') = 1 given 95 %3E 59%0A         */%0A        Arrays.sort(str, comp); // acsending order regarding to comp, which prefers the -1 output of comp.%0A
 %0A   

Add comments on the comparator.