human
I found an interesting problem on https://leetcode.com/problems/largest-number/:
Given a list of non negative integers, arrange them such that they form the largest number.

Example 1:

Input: [10,2]
Output: "210"

Example 2:

Input: [3,30,34,5,9]
Output: "9534330"

Note: The result may be very large, so you need to return a string instead of an integer.

I tried it in Python, but could not do it. Can you solve it?
assistant
#Here is the Python code you requested.

class Solution:
     def largestNumber(self, nums):
         """
         :type nums: List[int]
         :rtype: str
         """
         s=self.sort(nums)
         if s.startswith("0"):
             return "0"
         else:return s
     def sort(self,nums):
         if not nums:return ""
         else:
             pivot=nums[0]
             left=[]
             right=[]
             for i in range(1,len(nums)):
                 if self.compare(nums[i],pivot):
                     left.append(nums[i])
                 else:
                     right.append(nums[i])
             return self.sort(left)+str(pivot)+self.sort(right)
             
     def compare(self,num1,num2):
         num1,num2=str(num1),str(num2)
         return int(num1+num2)>int(num2+num1)