private List<Aircraft> SortResult(List<Aircraft> unsorted, string compare_icao) { string reg_wake = ICAO.GetWake(compare_icao); string reg_eng_type = ICAO.GetEngineType(compare_icao); int reg_eng_count = ICAO.GetEngineCount(compare_icao); // assign match to result aircrafts if (unsorted.Count > 1) { foreach (Aircraft temp_ac in unsorted) { temp_ac.match_count = 0; if (reg_wake == temp_ac.wake) temp_ac.match_count = 4; if (reg_eng_type == temp_ac.engine_type) temp_ac.match_count += 2; if (reg_eng_count == temp_ac.engine_count) temp_ac.match_count += 2; int min1 = Math.Min(2, compare_icao.Length); int min2 = Math.Min(2, temp_ac.icao.Length); int min3 = Math.Min(3, compare_icao.Length); int min4 = Math.Min(3, temp_ac.icao.Length); if (compare_icao.Substring(0, min1) == temp_ac.icao.Substring(0, min2)) temp_ac.match_count += 1; if (compare_icao.Substring(0, min3) == temp_ac.icao.Substring(0, min4)) temp_ac.match_count += 2; if (temp_ac.title.Contains(compare_icao.Substring(0, min3))) temp_ac.match_count += 1; } unsorted.Sort(delegate(Aircraft a1, Aircraft a2) { return a1.match_count.CompareTo(a2.match_count); }); unsorted.Reverse(); } return unsorted; }
public void Fill() { wake = ICAO.GetWake(icao); engine_type = ICAO.GetEngineType(icao); engine_count = ICAO.GetEngineCount(icao); }