Sort and Swap
We convert num to a string and then:\n- If negative: sort descending, excluding the sign.\n- If positive: sort ascending\n\t- Find first non-zero number (e.g. 0
We convert `num` to a string and then:\n- If negative: sort descending, excluding the sign.\n- If positive: sort ascending\n\t- Find first non-zero number (e.g. 000**2**37)\n\t- Swap it with the first number (e.g. **2**00**0**37)\n\n**Python**\n```python\nclass Solution:\n    def smallestNumber(self, num: int) -> int:\n        s = sorted(str(abs(num)), reverse = num < 0)\n        non_zero = next((i for i, n in enumerate(s) if n != \'0\'), 0)\n        s[0], s[non_zero] = s[non_zero], s[0]\n        return int(\'\'.join(s)) * (1 if num >= 0 else -1)\n```\n**C++**\n```cpp\nlong long smallestNumber(long long num) {\n    auto s = to_string(abs(num));\n    sort(begin(s), end(s), [&](int a, int b){ return num < 0 ? a > b : a < b; });\n    if (num > 0)\n        swap(s[0], s[s.find_first_not_of(\'0\')]);\n    return stoll(s) * (num < 0 ? -1 : 1);\n}\n```
[]