C++ code | using vector and sort | 0ms beats100% soln
\nclass Solution {\npublic:\n    long long smallestNumber(long long num) {\n        if(num == 0)return 0;\n        int isneg = 0;\n        if(num < 0) isneg = 1
```\nclass Solution {\npublic:\n    long long smallestNumber(long long num) {\n        if(num == 0)return 0;\n        int isneg = 0;\n        if(num < 0) isneg = 1 , num = -num;\n        vector<int> digits;\n        \n        while(num > 0)\n        {\n            digits.push_back(num%10);\n            num = num/10;\n        }\n     \n        sort(digits.begin(),digits.end());\n        long long res = 0;\n        \n        if(!isneg)\n        {\n            int i = 0;\n        while(digits[i] == 0) \n        {\n            i++;\n        }\n        res = digits[i];\n        digits[i] = -1;\n        for(auto  it : digits)\n        {\n            if(it >= 0)\n            res = res*10 + it;\n        }\n        \n    }\n        else\n        {\n            for(int index = digits.size() - 1; index >= 0 ; index--)\n                res = res * 10 + digits[index];\n            \n            return -res;\n        }\n        \n        return res;\n        \n    }\n};\n```
['C', 'Sorting']