"""Leetcode 179. Largest Number
Medium

URL: 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.
"""

class Solution(object):
    def largestNumber(self, nums):
        """
        :type nums: List[int]
        :rtype: str
        """
        pass


def main():
    pass


if __name__ == '__main__':
    main()

@@ -378,16 +378,30 @@
 Solution
+SortComparator
 (object)
@@ -503,55 +503,977 @@
 str%0A
-        %22%22%22%0A        pass%0A%0A%0Adef main():%0A    pass
+%0A        Time complexity: O(m*n*logn), where %0A          - n is the length of numbers%0A          - m is the max length of numbers%0A        Space complexity: O(m+n)%0A        %22%22%22%0A        # Check any of numbers is larger than 0.%0A        if not any(nums):%0A            return '0'%0A%0A        # Convert number list to string list.%0A        num_strs = %5Bstr(n) for n in nums%5D%0A%0A        # Sort string list by built-in sort with comparator.%0A        def comparator(x, y):%0A            if x + y %3E y + x:%0A                return -1%0A            elif x + y %3C y + x:%0A                return 1%0A            else:%0A                return 0%0A%0A        num_strs.sort(cmp=comparator)%0A%0A        return ''.join(num_strs)%0A%0A%0Adef main():%0A    # Output: %22210%22%0A    nums = %5B10,2%5D%0A    print SolutionSortComparator().largestNumber(nums)%0A%0A    # Output: %229534330%22%0A    nums = %5B3,30,34,5,9%5D%0A    print SolutionSortComparator().largestNumber(nums)%0A%0A    nums = %5B0,0%5D%0A    print SolutionSortComparator().largestNumber(nums)    
 %0A%0A%0Ai

Complete sort+comparamter sol