```
string largestNumber(vector<int>& nums) {
vector<string> vs;
string s="";
for(int &num:nums) vs.push_back(to_string(num));
sort(vs.begin(),vs.end(),[](string a,string b){return a+b>b+a;});
if(vs[0][0]=='0') return "0"; //deal with all "0" value
for(string & ss:vs) s+=ss;
return s;
}
```

Why does this solution work?

First, we need to show the comparator works, or the array is sortable. Meaning if A comes before B and B comes before C, then A must comes before C.

Next, we must prove after sorting, by concatenating the array,we get the largest number.

The first proof is by @19thhell.

Let A, B, C be the integer given. To concatenate A and B into AB, we need to know how many digits are there in B, then multiply power of 10 with A, add B to the result. Example: 12312 = 123 * 100 + 12. The number of digits in B is lgB + 1, therefore we need to multiply A with 10^(lgB + 1), then add the result with B to get AB. Now we can start our proof.

```
Proof:
Let us define f(X) = 10^(lgX + 1), then XY = f(Y)X + Y
If AB <= BA, then we have
f(B)A + B <= f(A)B + A
(f(B) - 1)A <= (f(A) - 1)B
that is
A <= B·(f(A) - 1) / (f(B) - 1) (1)
If BC <= CB, then we have
f(C)B + C <= f(B)C + B
(f(C) - 1)B <= (f(B) - 1)C
that is
B <= C·(f(B) - 1) / (f(C) - 1) (2)
Combine (1), (2), we have
A <= C·(f(A) - 1) / (f(C) - 1)
(f(C) - 1)A <= (f(A) - 1)C
f(C)A + C <= f(A)C + A
AC <= CA
```

The second proof:

First, some properties. (IF THE IMAGE BELOW IS NOT SHOWN PROPERLY, OPEN IT IN ANOTHER WINDOW OR DOWNLOAD IT)