Given a list of non negative integers, arrange them in such a manner that they form the largest number possible.The result is going to be very large, hence return the result in the form of a string.
Example 1:
Input: 
N = 5
Arr[] = {3, 30, 34, 5, 9}
Output: 9534330
Explanation: Given numbers are {3, 30, 34,
5, 9}, the arrangement 9534330 gives the
largest value.
Example 2:
Input: 
N = 4
Arr[] = {54, 546, 548, 60}
Output: 6054854654
Explanation: Given numbers are {54, 546,
548, 60}, the arrangement 6054854654 
gives the largest value.
Your Task:  
You don't need to read input or print anything. Your task is to complete the function printLargest() which takes the array of strings arr[] as parameter and returns a string denoting the answer.
Expected Time Complexity: O(NlogN)
Expected Auxiliary Space: O(N)
Constraints:
1 ≤ N ≤ 10^{5}
0 ≤ Arr[i] ≤ 10^{18}
Sum of all the elements of the array is greater than 0.

Difficulty: MEDIUM
Tags: Data structures
Skill types: Data structures
Expected Time Complexity: O(NlogN)
Expected Auxiliary Space: O(N)

Starter code:
#User function Template for python3

class Solution:



	def printLargest(self,arr):

	    # code here



Solutions:
import functools

class Solution:

	def compair(self, x, y):
		if x + y > y + x:
			return -1
		else:
			return 1

	def printLargest(self, arr):
		arr.sort(key=functools.cmp_to_key(self.compair))
		return ''.join(map(str, arr))


class Solution:

	def printLargest(self, arr):
		import functools

		def comparison(a, b):
			if a + b < b + a:
				return 1
			else:
				return -1
		arr.sort(key=functools.cmp_to_key(comparison))
		return ''.join(map(str, arr))


class Solution:

	def printLargest(self, arr):
		arr = list(map(str, arr))

		def compare(a, b):
			ab = a + b
			ba = b + a
			if ab > ba:
				return -1
			elif ab < ba:
				return 1
			else:
				return 0
		arr.sort(key=functools.cmp_to_key(compare))
		largestNumber = ''.join(arr)
		return largestNumber


class Solution:

	def printLargest(self, arr):
		import functools

		def compare(a, b):
			if a + b > b + a:
				return -1
			return 1
		arr.sort(key=functools.cmp_to_key(compare))
		return ''.join(arr)


class Solution:

	def printLargest(self, arr):
		return ''.join(sorted(arr, reverse=True, key=lambda _: _ * 18))


from functools import cmp_to_key

class Solution:

	def printLargest(self, arr):
		for (i, v) in enumerate(arr):
			arr[i] = str(v)

		def compare(n1, n2):
			if n1 + n2 > n2 + n1:
				return -1
			else:
				return 1
		arr = sorted(arr, key=cmp_to_key(compare))
		return ''.join(arr)


class Solution:

	def printLargest(self, arr):
		arr = list(map(str, arr))

		def compare_numbers(a, b):
			order1 = a + b
			order2 = b + a
			if order1 > order2:
				return -1
			elif order1 < order2:
				return 1
			else:
				return 0
		arr.sort(key=functools.cmp_to_key(compare_numbers))
		largest_num = ''.join(arr)
		return largest_num


import functools

class Solution:

	def sortfunc(self, a, b):
		if a + b > b + a:
			return 1
		else:
			return -1

	def printLargest(self, arr):
		l = len(arr)
		for i in range(l):
			arr[i] = str(arr[i])
		arr.sort(reverse=True, key=functools.cmp_to_key(self.sortfunc))
		ans = ''.join(arr)
		return ans


import functools

class Solution:

	def printLargest(self, nums):
		for (i, n) in enumerate(nums):
			nums[i] = str(n)

		def compare(n1, n2):
			if n1 + n2 > n2 + n1:
				return -1
			else:
				return 1
		nums.sort(key=functools.cmp_to_key(compare))
		return ''.join(map(str, nums))


from functools import cmp_to_key

class Solution:

	def printLargest(self, arr):

		def compare(s1, s2):
			s12 = s1 + s2
			s21 = s2 + s1
			if s21 > s12:
				return 1
			else:
				return -1
		asorted = sorted(arr, key=cmp_to_key(compare))
		return ''.join(asorted)


class Solution:

	def printLargest(self, arr):
		arr = [str(x) for x in arr]
		arr.sort(key=lambda x: x * 8, reverse=True)
		return ''.join(arr)


class Solution:

	def printLargest(self, arr):

		def myKey(a, b):
			if a + b > b + a:
				return -1
			elif a + b < b + a:
				return 1
			else:
				return 0
		ans = ''
		l = sorted(arr, key=functools.cmp_to_key(myKey))
		for i in l:
			ans += i
		return ans


class Solution:

	def printLargest(self, arr):
		arr = list(map(str, arr))

		def compare(a, b):
			if a + b > b + a:
				return -1
			else:
				return 1
		arr = sorted(arr, key=functools.cmp_to_key(compare))
		result = ''.join(arr)
		result = result.lstrip('0')
		if result == '':
			return '0'
		else:
			return result


class Solution:

	def compare(self, a, b):
		if a + b > b + a:
			return -1
		return 1

	def printLargest(self, arr):
		arr = [str(i) for i in arr]
		arr.sort(key=functools.cmp_to_key(self.compare))
		return ''.join(arr)


class Solution:

	def printLargest(self, arr):
		s = sorted(arr, key=lambda x: x * 18)
		return ''.join(s[::-1])


from itertools import *

class Solution:

	def printLargest(self, arr):

		def comp(a, b):
			if a + b > b + a:
				return -1
			return 1
		arr = sorted(arr, key=functools.cmp_to_key(comp))
		return ''.join(map(str, arr))
		ans = ''
		for i in range(n - 1):
			for j in range(i + 1, n):
				if int(str(arr[i]) + str(arr[j])) > int(str(arr[j]) + str(arr[i])):
					pass
				else:
					(arr[i], arr[j]) = (arr[j], arr[i])
		for i in range(n):
			ans += str(arr[i])
		return ans


from filecmp import cmp
from functools import cmp_to_key

class Solution:

	def printLargest(self, arr):
		return ''.join(sorted(arr, reverse=True, key=lambda _: _ * 18))


class Solution:

	def printLargest(self, arr):
		arr = [str(i) for i in arr]
		arr.sort(key=lambda x: x * 10, reverse=True)
		largest_num = ''.join(arr)
		return largest_num


class largest(str):

	def __lt__(x, y):
		return x + y > y + x

class Solution:

	def printLargest(self, arr):
		arr = [str(x) for x in arr]
		arr.sort(key=largest)
		return ''.join(arr)


class Solution:

	def printLargest(self, arr):
		arr.sort(key=lambda x: x * 10, reverse=True)
		return ''.join(arr)


class Solution:

	def comparator(self, a, b):
		if a + b < b + a:
			return 1
		return -1

	def printLargest(self, arr):
		arr.sort(key=functools.cmp_to_key(self.comparator))
		return ''.join(arr)


from functools import cmp_to_key

class Solution:

	def compare(self, s1, s2):
		s12 = s1 + s2
		s21 = s2 + s1
		if s12 <= s21:
			return -1
		else:
			return 1

	def printLargest(self, a):
		a_sorted = sorted(a, key=cmp_to_key(self.compare), reverse=True)
		return ''.join(a_sorted)


import functools

class Solution:

	def printLargest(self, arr):

		def fun(a, b):
			x = a + b
			y = b + a
			if x > y:
				return 1
			else:
				return -1
		arr = sorted(arr, key=functools.cmp_to_key(fun), reverse=True)
		return ''.join(arr)


import functools

def myCompare(x, y):
	return 1 if x + y > y + x else -1

class Solution:

	def printLargest(self, arr):
		arr.sort(key=functools.cmp_to_key(myCompare))
		arr.reverse()
		s = ''.join(map(str, arr))
		return s


class Large(str):

	def __lt__(x, y):
		return x + y > y + x

class Solution:

	def printLargest(self, arr):
		if len(arr) == 1:
			return str(arr)
		arr = list(map(str, arr))
		arr.sort(key=Large)
		return ''.join(arr)


class Solution:

	def printLargest(self, arr):
		arr = list(map(str, arr))
		arr.sort(key=lambda x: x * 10, reverse=True)
		s = ''.join(arr)
		return s


class Solution:

	def printLargest(self, arr):
		nums = [str(num) for num in arr]

		def compare(a, b):
			if a + b > b + a:
				return -1
			elif a + b < b + a:
				return 1
			else:
				return 0
		arr.sort(key=functools.cmp_to_key(compare))
		return ''.join(arr)


class Solution:

	def printLargest(self, arr):

		class cmp(str):

			def __lt__(self, other):
				return self + other < other + self
		arr = sorted(arr, key=cmp, reverse=True)
		return ''.join(arr)


class Solution:

	def my_fuc(self, a, b):
		if a + b > b + a:
			return -1
		return 1

	def printLargest(self, arr):
		arr.sort(key=functools.cmp_to_key(self.my_fuc))
		answer = ''.join(map(str, arr))
		if answer[0] == '0':
			return 0
		return answer


import functools

def compare(x, y):
	s1 = x
	s2 = y
	ss1 = s1
	s1 = s1 + s2
	s2 = s2 + ss1
	if s1 >= s2:
		return 1
	return -1

class Solution:

	def printLargest(self, arr):
		arr.sort(key=functools.cmp_to_key(compare))
		arr = arr[::-1]
		return ''.join(map(str, arr))


class Solution:

	def printLargest(self, arr):
		n = len(arr)
		for i in range(n):
			arr[i] = str(arr[i])
		arr.sort(key=lambda x: x * 10, reverse=True)
		res = ''.join(arr)
		return res


import functools

class Solution:

	def printLargest(self, arr):

		def compare(a, b):
			if a + b > b + a:
				return -1
			else:
				return 1
		arr = sorted(arr, key=functools.cmp_to_key(compare))
		result = ''.join(arr)
		result = result.lstrip('0')
		if result == '':
			return '0'
		else:
			return result


class Solution:

	def printLargest(self, a):
		n = len(a)
		maxdigit = 0
		for i in range(n):
			maxdigit = max(maxdigit, len(a[i]))
		maxdigit += maxdigit
		for i in range(n):
			x = len(a[i])
			cnt = 0
			while len(a[i]) < maxdigit:
				if len(a[i]) == maxdigit - 1:
					a[i] += str(cnt)
				else:
					a[i] += a[i][cnt % x]
					cnt += 1
		a.sort(reverse=True)
		ans = ''
		for i in range(n):
			x = a[i][-1]
			ans += a[i][0:len(a[i]) - int(x) - 1]
		return ans


class Solution:

	def printLargest(self, nums):
		num = [str(x) for x in nums]
		num.sort(key=functools.cmp_to_key(lambda b, a: (a + b > b + a) - (a + b < b + a)))
		return ''.join(num).lstrip('0') or '0'


class Solution:

	def printLargest(self, arr):
		arr.sort(key=functools.cmp_to_key(comp))
		ans = ''.join(arr)
		return ans

def comp(a, b):
	s1 = a + b
	s2 = b + a
	if s1 < s2:
		return 1
	return -1


class Solution:

	def mycmp(self, a, b):
		if a + b > b + a:
			return 1
		elif a + b < b + a:
			return -1
		else:
			return 0

	def printLargest(self, arr):
		for i in range(len(arr)):
			arr[i] = str(arr[i])
		ans = ''.join(sorted(arr, reverse=True, key=functools.cmp_to_key(self.mycmp)))
		return ans


from functools import cmp_to_key

class Solution:

	@staticmethod
	def compare(s1, s2):
		if s2 + s1 > s1 + s2:
			return 1
		else:
			return -1

	def printLargest(self, arr):
		arr.sort(key=cmp_to_key(Solution.compare))
		return ''.join(arr)


class Solution:

	def printLargest(self, x):

		def sum(x, y):
			xy = x + y
			yx = y + x
			if yx > xy:
				return 1
			return -1
		x.sort(key=functools.cmp_to_key(sum))
		res = ''.join(x)
		return res