Given an array of numbers where every number is represented as string. The numbers may be very large (may not fit in long long int), the task is to sort these numbers.

Examples:

Input : arr[] = {"5", "1237637463746732323", "12" };
Output : arr[] = {"5", "12", "1237637463746732323"};

Input : arr[] = {"50", "12", "12", "1"};
Output : arr[] = {"1", "12", "12", "50"};
// C# program to sort large numbers 
// represented as strings. 
using System; 

class GFG 
{ 

	// Function for sort an array of large 
	// numbers represented as strings 
	static void sortLargeNumbers(String []arr) 
	{ 
		// Refer below post for understanding 
		// below expression: 
		// https://www.geeksforgeeks.org/lambda-expressions-java-8/ 
		for(int i = 0; i < arr.Length - 1; i++) 
		{ 
			/* If length of left != right, then 
			return the diff of the length else 
			use compareTo function to compare values.*/
			String left = arr[i], right = arr[i + 1]; 
			if (left.Length > right.Length) 
			{ 
				arr[i] = right; 
				arr[i + 1] = left; 
				i -= 2; 
			} 
		} 
	} 

	// Driver code 
	public static void Main() 
	{ 
		String []arr = {"5", "1237637463746732323", 
						"97987", "12" }; 
		sortLargeNumbers(arr); 
		foreach (String s in arr) 
			Console.Write(s + " "); 
	} 
} 

// This code is contibuted by PrinciRaj1992 
Output:

5 12 97987 1237637463746732323