string[] iniArray = { "M Facci", "D Thornton", "B Luke", "S Tofani", "T Luke" };
var sortedArray = iniArray.OrderBy(r => r.Split(' ').Last()).ToArray();
or (courtesy @killercam)
var sortedArray = iniArray.OrderBy(r => r.Split().Last()).ToArray();
Assuming there is only First Name and Last Name in a string, also, there exists a Last Name.
To display the resulted array:
foreach (string str in sortedArray)
{
Console.WriteLine(str);
}
Output would be:
M Facci
B Luke
T Luke
D Thornton
S Tofani
5
solved Sorting Array in c# [closed]