# 179 largest number

```java
class Solution {
    public String largestNumber(int[] nums) {
        String[] numbers = new String[nums.length];
        for (int i = 0; i < nums.length; i++) {
            numbers[i] = String.valueOf(nums[i]);
        }
        Arrays.sort(numbers, new Comparator<String>() {
            @Override
            public int compare(String a, String b){
                String order1 = a + b;
                String order2 = b + a;
                return order1.compareTo(order2);
            }
        });
        if (numbers[numbers.length - 1].equals("0")) {
            return "0";
        }
        String ans = "";
        for (int i = numbers.length - 1; i >= 0; i--) {
            ans += numbers[i];
        }
        return ans;
    }
}
```

注意comparator的妙用，把两两组合后在先时结果较大的数排在前面

同时注意valueOf的使用，用于转int为string
