// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Linq; using System.Text.RegularExpressions; namespace E { public class Program { public static void Main(string[] args) { Regex letters = new Regex(@"[a-zA-Z]\w*"); Regex numeric = new Regex(@"\d+"); string indexs = "4h,14h,9q,8p,3h,0z"; string[] tmp = indexs.Split(','); Array.Sort(tmp, (s1,s2) => letters.Match(s1).Value==letters.Match(s2).Value ? int.Parse(numeric.Match(s2).Value) - int.Parse(numeric.Match(s1).Value) : letters.Match(s1).Value.CompareTo(letters.Match(s2).Value)); indexs = string.Join(",", tmp); Console.WriteLine(indexs); } } }