我如何能實現IComparer
C#IComparable的IComparer的額外帕拉姆
int CompareTo(object obj)
有附加參數,如
int CompareTo(object obj, Dictionary<int, int> preferences)
喜好是Id
字典和NumberOfClicks<int, int>
我想要的是比較e字典中的點擊次數爲categoryId的內容,
示例Cat 1有3次點擊,Cat 2有6次點擊。
排序比較 preferences[this.CategoryId].value > preferences[object.CategoryId].value
所以他們按類別排序,但相對於Dictionary
。
您顯示的簽名來自「IComparable」,而不是「IComparer」。 – dasblinkenlight