✅ Commented || C++ Faster than 100% submissions || sorting and swapping
\nclass Solution {\npublic:\n    long long smallestNumber(long long num) {\n        if(num<=10&&num>=0)\n            return num;\n        vector<long long> arr;
```\nclass Solution {\npublic:\n    long long smallestNumber(long long num) {\n        if(num<=10&&num>=0)\n            return num;\n        vector<long long> arr;\n        long long sum=0;\n        if(num>0){\n            //for positive number\n            while(num){\n                arr.push_back(num%10);\n                num/=10;\n                \n            }\n            //sort in increasing order for +ve num\n            sort(arr.begin(),arr.end());\n            if(!arr[0]){\n                for(long long i=0;i<arr.size();i++){\n                    if(arr[i]){\n                       swap(arr[i],arr[0]);\n                        break;\n                        \n                    }\n                        \n                }\n            }\n            long long n= arr.size();\n            for(long long i=0;i<arr.size();i++){\n                sum=sum*10+arr[i];\n                \n            }\n            \n        }\n        else{\n            //for -ve number\n            num*=-1; // making num +ve to carry operations\n            while(num){\n                arr.push_back(num%10);\n                num/=10;\n                \n            }\n            //sort in decreasing order for -ve num\n            sort(arr.begin(),arr.end(),greater<long long>());\n            long long n= arr.size();\n            if(!arr[0]){\n                for(long long i=0;i<n;i++){\n                    if(arr[i]){\n                       swap(arr[i],arr[0]);\n                        break;\n                        \n                    }\n                        \n                }\n            }\n            \n            for(long long i=0;i<arr.size();i++){\n                sum=sum*10+arr[i];\n                \n            }\n            // making num -ve\n            sum*=-1;\n            \n        }\n        return sum;\n    }\n};\n```\n\n**Upvote if u liked it**
['C', 'Sorting', 'C++']