class Solution
{
public:
    bool static cmp(string a, string b)
    {
        return (a + b) > (b + a); //当a+b>b+a时a排在b前面
    }
    string largestNumber(vector<int> &nums)
    {
        int flag = 0;
        vector<string> v;
        for (vector<int>::iterator i = nums.begin(); i < nums.end(); i++)
        {
            v.push_back(to_string(*i));
            if (*i)
                flag = 1;
        }
        if (!flag)
            return "0";
        sort(v.begin(), v.end(), cmp); //没有生成实例就要调用，故cmp应声明为static
        string s = "";
        for (int i = 0; i < v.size(); i++)
            s = s + v[i];
        return s;
    }
};