C++ | Easy and Concise Solution | Sorting | 100% Fast Working
\nclass Solution {\npublic:\n    long long smallestNumber(long long num) \n    {\n        string s="";\n        int c=0;\n        if(num<0) c++;\n        num=ab
```\nclass Solution {\npublic:\n    long long smallestNumber(long long num) \n    {\n        string s="";\n        int c=0;\n        if(num<0) c++;\n        num=abs(num);\n        while(num!=0)\n        {\n            s+=num%10+\'0\';\n            num/=10;\n        }\n        long long n=0;\n        if(c==0)\n        {\n            sort(s.begin(),s.end());\n            cout<<s;\n            if(s[0]==\'0\')\n            {\n                for(int i=1;i<s.size();i++)\n                {\n                    if(s[i]!=\'0\')\n                    {\n                        swap(s[i],s[0]);\n                        break;\n                    }\n                }\n            }\n            int i=0;\n            while(i<s.size())\n            {\n                n=n*10+(s[i]-\'0\');\n                i++;\n            }\n        }\n        else\n        {\n            sort(s.rbegin(),s.rend());  \n            int i=0;\n            while(i<s.size())\n            {\n                n=n*10+(s[i]-\'0\');\n                i++;\n            }\n            n*=-1;\n        }\n        return n;        \n    }\n};\n```
['C', 'Sorting', 'C++']