public static void SortPathByDistance(List <HexCell> path, HexCell destination) { path.Sort( delegate(HexCell a, HexCell b) { int aDistance = destination.GetDistance(a); int bDistance = destination.GetDistance(b); return(bDistance.CompareTo(aDistance)); }); }