using System;
using System.Linq;
using System.Collections.Generic;
namespace MyCompiler {
class Program {
public static void Main(string[] args)
{
Console.WriteLine("Hello world!");
reverse(new string[] {"John Locke","Thomas Aquinas","David Hume","Rene Descartes"}, "ASC");
reverse(new string[] {"Paul Erdos","Leonhard Euler","Carl Gauss"}, "DESC");
reverse(new string[] {}, "DESC");
//reverse(null, "DESC");
}
public static void reverse(string[] arr,string str)
{
//if(arr == null) return new string[]{};
SortedDictionary<string,string> sd = new SortedDictionary<string,string>();
List<string> lis = new List<string>();
foreach(string ele in arr)
{
sd.Add(ele.Split(' ')[1],ele.Split(' ')[0]);
}
foreach(KeyValuePair<string,string> item in sd)
{
lis.Add(item.Value +" "+ item.Key);
}
List<string> lis2 = new List<string>(lis);
lis2.Reverse();
Console.WriteLine(string.Join(" || ",str == "ASC"?lis : lis2));
}
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: