#main idea: change the default implementation for comparison and sort in descending order.
class Solution:
def largestNumber(self, nums: List[int]) -> str:
# time O(NlgN) space O(N)
comp = lambda a,b:1 if a+b > b+a else -1 if a+b < b+a else 0
_nums = list(map(str,nums)) # here add a list() is to convert map object into list type, for the intention to sort below; because we can not sort inplace. but if using sorted() will work without list() to pre process
_nums.sort(reverse=True,key=functools.cmp_to_key(comp))
# str int double typle conversion is to handle the case if input nums is a list of [0,0,0], where we can only return '0'
return str(int(''.join(_nums)))