using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static string ExtractName(string s) {
int pos = s.LastIndexOf(' ');
return s.Substring(0, pos);
}
static void Main()
{
var lst = new List<string>
{
"Python 4", "C 9", "C++ 5", "C# 6",
"Java 1", "PHP 7", "Go 2"
};
var sorted = lst.OrderBy(s => ExtractName(s)).ToList();
foreach (var item in sorted)
Console.WriteLine(item);
}
}
/*
run:
C 9
C# 6
C++ 5
Go 2
Java 1
PHP 7
Python 4
*/