simple and easy C++ solution
\n# if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n###### Let\'s Connect on LinkedIn: www.linkedin.com/in/shishirrsiam\n###### Let\'s Connect on Facebook
\n# if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n###### Let\'s Connect on LinkedIn: www.linkedin.com/in/shishirrsiam\n###### Let\'s Connect on Facebook: www.fb.com/shishirrsiam\n\n# Complexity\n- Time complexity: O(dlogd), where \uD835\uDC51 is the number of digits in the input number num.\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(d)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    long long positiveNum(string &nums)\n    {\n        string numbers, zero;\n        for(auto ch:nums)\n            ch == \'0\' ? zero += ch : numbers += ch;\n        sort(begin(numbers), end(numbers));\n        numbers.insert(1, zero);\n        return stoll(numbers);\n    }\n    long long smallestNumber(long long num) \n    {\n        if(num == 0) return 0;\n        string nums = to_string(num);\n        if(nums[0] == \'-\')\n        {\n            sort(nums.rbegin(), nums.rend());\n            return - stoll(nums);\n        }\n        return positiveNum(nums);\n    }\n};\n```
['Math', 'Sorting', 'C++']