我有一个带有companyNames的字符串列表,
1. CompanyA
2. CompanyB
3. CompanyA
4. CompanyC
我的方法是:
Dim companyNames = From cp In companyList
Order By If(cp.CompanyName = 'CompanyC', 1, 0) Descending
Select cp.CompanyName
Distinct
但我得到了结果:
1. CompanyC
1. CompanyB
2. CompanyA
我希望在设置“CompanyC”之前按公司名称订单保留订单。 ,我想要以下结果
1. CompanyC
2. CompanyA
3. CompanyB
答案 0 :(得分:5)
您需要CompanyName Ascending
的其他订单:
Dim companyNames =
From cp In companyList
Order By If(cp.CompanyName = "CompanyC", 1, 0) Descending, CompanyName Ascending
Select cp.CompanyName
Distinct