✅ C++ || Sort || 0ms || East to Understanding
\nclass Solution {\npublic:\n    long long smallestNumber(long long num) {\n        string s=to_string(abs(num)); //long long to string\n        sort(s.begin(),
```\nclass Solution {\npublic:\n    long long smallestNumber(long long num) {\n        string s=to_string(abs(num)); //long long to string\n        sort(s.begin(),s.end()); // sort the string\n        int i=0;\n        long long res;\n        if(num<=0){ //if negetive number\n            reverse(s.begin(),s.end());  // reverse the string\n            res= -stoll(s); //string to long long\n        }\n        else{ // if positive\n            while(s[i]==\'0\'){ //come upto first non zero number\n                i++;\n            }\n            swap(s[0],s[i]); // now swap first digit with first non zero number\n            res= stoll(s); //string to long long \n        }\n        return res;\n    }\n};\n```\n*If you have any doubt, feel free to ask below.*\n**Upvote if you like this!**
['String', 'C', 'Sorting']