private void InsertComparisonRecordsSorted(ComparisonRecordInfoWrapper wrappedComparisonRecordInfo) { if (!ComparisonRecords.Any()) { ComparisonRecords.Add(wrappedComparisonRecordInfo); return; } var list = new List <ComparisonRecordInfoWrapper>(ComparisonRecords) { wrappedComparisonRecordInfo }; List <ComparisonRecordInfoWrapper> orderedList = null; if (UseComparisonGrouping) { orderedList = IsSortModeAscending ? list.OrderBy(x => x.WrappedRecordInfo.Game).ThenBy(x => x.WrappedRecordInfo.FirstMetric).ToList() : list.OrderBy(x => x.WrappedRecordInfo.Game).ThenByDescending(x => x.WrappedRecordInfo.FirstMetric).ToList(); } else { orderedList = IsSortModeAscending ? list.OrderBy(x => x.WrappedRecordInfo.FirstMetric).ToList() : list.OrderByDescending(x => x.WrappedRecordInfo.FirstMetric).ToList(); } if (orderedList != null) { var index = orderedList.IndexOf(wrappedComparisonRecordInfo); ComparisonRecords.Insert(index, wrappedComparisonRecordInfo); } }