Largest Number LeetCode solution in Python
1from functools import cmp_to_key234class Solution:5def largestNumber(self, nums: List[int]) -> str:6nums = list(map(str, nums))7nums = reversed(8sorted(9nums,10key=cmp_to_key(11lambda x, y: (12-113if int(x + y) < int(y + x)14else (1 if int(x + y) > int(y + x) else 0)15)16),17)18)19res = "".join(nums)20return res if int(res) else "0"