using System.Collections.Generic; using Fantasy; namespace NBF { public static class ShopItemHelper { public static List ToTabItemData(this List shopItems) { List ret = new List(); Dictionary> tabDic = new Dictionary>(); foreach (var shopItemInfo in shopItems) { var type = shopItemInfo.ItemType; if (!tabDic.ContainsKey(type)) { tabDic.Add(type, new List()); } tabDic[type].Add(shopItemInfo); } foreach (var (key, list) in tabDic) { list.Sort((x, y) => (int)(y.Price1 - x.Price1)); } foreach (var (type, list) in tabDic) { TabItemData tabItem = new TabItemData { Key = type.ToString() }; tabItem.Items.AddRange(list); ret.Add(tabItem); } return ret; } } }