Simple solution using stringstream
\nclass Solution {\npublic:\n    long long smallestNumber(long long num) {\n        if (num <= 10 && num >= -10)\n                return num;\n        if (num <
```\nclass Solution {\npublic:\n    long long smallestNumber(long long num) {\n        if (num <= 10 && num >= -10)\n                return num;\n        if (num <= 100 && num >= -100 && num % 10 == 0)\n            return num;\n        if (num > 0)\n        {\n            string pos = to_string(num);\n            sort(pos.begin(), pos.end());\n            if (pos[0] == \'0\')\n            {\n                for (int i = 0; i < pos.length(); i++)\n                    if (pos[i] != \'0\')\n                    {\n                        swap(pos[0], pos[i]);\n                        break;\n                    }\n            }\n            stringstream ans(pos);\n            long long x = 0;\n            ans >> x;\n            return x;\n        }\n        \n        else\n        {\n            string neg = to_string(num);\n            sort(neg.begin(), neg.end(), greater<int>());\n            stringstream ans(neg);\n            long long x = 0;\n            ans >> x;\n            return -x;\n        }\n        \n        return 0;\n    }\n};\n```\n**Use of stringstream**  - ```stringstream``` covert string to any data type like ```float```, ```int```, ```double```, ```long long``` etc. easily.
['C++']