0
我有一个SortedDictionary
其中密钥是对类商店的引用。值为List<Item>
。如何使用键和值一起对SortedDictionary进行排序?
我想排序字典中的商店。 IComparer
只能应用于Key
的值。
但是,对于正确的排序,需要Value(List<Item>
)中的数据。价格为例。
我该怎么做? 使用SortedDictionary可选,我会处理任何决定。 重要的是,我可以快速获得钥匙的价值,类似于TryGetValue
。
class Item
{
int price;
string name;
}
class Store
{
string owner;
string street;
string city;
}
SortedDictionary<Store, List<Item>>
也许'SortedDictionary <商店,SortedSet的- >'? –
不,我需要对商店的列表/字典进行排序。使用货物价格的数据。 – Mixer
您可以将'Store'类的'List- '部分作为字段,然后您就可以按照自己想要的方式对商店列表进行排序。 –
Yuriy