[Python] Easy and Concise with Explanation
Explanation\nIf it\'s negative, simple sort reversely all digits.\nIf it\'s positive, swap the fisrt digit and the first non-zero digit.\n\nNote that 0 is neith
# **Explanation**\nIf it\'s negative, simple sort reversely all digits.\nIf it\'s positive, swap the fisrt digit and the first non-zero digit.\n\nNote that `0` is neither positive nor negative,\ntake care of it.\n<br>\n\n**C++**\nall by @blackspinner\n```cpp\n    long long smallestNumber(long long num) {\n        string s = to_string(abs(num));\n        sort(s.begin(), s.end());\n        if (num <= 0) {\n            return -1 * stoll(string(s.rbegin(), s.rend()));\n        }\n        int i = s.find_first_not_of(\'0\');\n        swap(s[0], s[i]);\n        return stoll(s);\n    }\n```\n**Python**\n```py\n    def smallestNumber(self, a):\n        s = sorted(str(abs(a)))\n        if a <= 0:\n            return -int(\'\'.join(s[::-1]))\n        i = next(i for i,a in enumerate(s) if a > \'0\')\n        s[i], s[0] = s[0], s[i]\n        return int(\'\'.join(s))\n```\n
['Python']