I receive a sorted list of integers which I would like to use to sort a ListCollectionView
via ListCollectionView.CustomSort
. This property accepts an IComparer
and I've created one but, as expected, I can only compare values on generic objects x
and y
.
public List<int> SortedIds = new List<int> { 13, 7, 5, 3, 1 };
public class Item {
int Id { get; set; }
}
public class IdComparer : IComparer<Item> {
public int Compare(Item x, Item y) {
// Comparisons
// ???
// return 0;
}
}