Alternative 1 (type safe sorting using generics):
private int ComparePass(Pass x, Pass y) { if (x.Starttid < y.Starttid) return -1; if (x.Starttid > y.Starttid) return 1; return 0; } : : Pass[] results = ...; Array.Sort<Pass>(results, ComparePass); :
Alternative 2 (type safe sorting using generics and an anonymous method):
Pass[] results = ...; Array.Sort<Pass>(results, delegate(Pass x, Pass y) { if (x.Starttid < y.Starttid) return -1; if (x.Starttid > y.Starttid) return 1; return 0; });
Alternative 3 (type safe sorting using generics and an anonymous method using a default comparer):
Pass[] results = ...; Array.Sort<Pass>(results, delegate(Pass x, Pass y) { return Comparer.Default.Compare(x.Starttid, y.Starttid); });