// 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; namespace E { public struct D { public int Id; public DateTime T1; public DateTime T2; } public class Program { public static void Main(string[] args) { D[] kontrol = new D[3]; kontrol[0].Id = 102; kontrol[0].T1 = DateTime.Now; kontrol[0].T2 = DateTime.Now.AddHours(1); kontrol[1].Id = 103; kontrol[1].T1 = DateTime.Now; kontrol[1].T2 = DateTime.Now.AddHours(2); kontrol[2].Id = 101; kontrol[2].T1 = DateTime.Now; kontrol[2].T2 = DateTime.Now.AddHours(3); Console.WriteLine("Before sort:"); foreach(D d in kontrol) { Console.WriteLine(d.Id + " " + d.T1 + " " + d.T2); } Array.Sort(kontrol, delegate(D x, D y){ return x.Id - y.Id; }); Console.WriteLine("After sort:"); foreach(D d in kontrol) { Console.WriteLine(d.Id + " " + d.T1 + " " + d.T2); } } } }