# 我有一个国家清单.我想按字母顺序排序，除了我想放在第一个的两个国家/地区[英] I have a list of countries. I'd like to sort it alphabetically, except for two countries which I'd like to put first

### 问题描述

```from country in Countries
orderby country.Name
select country
```

## 推荐答案

```var specialCountries = new[] { "America", "England" };

from country in Countries
orderby specialCountries.Contains(country.Name) descending, country.Name
select country
```

```from country in Countries
orderby (country.Name == "America" || country.Name == "England") descending, country.Name
select country
```

## 其他推荐答案

```var ordered = Countries.OrderByDescending(c => ConditionHere)
.ThenBy(c => c.Name);
```

```var priorCountries = new[]{ "Italy", "France" };
var ordered = Countries.OrderByDescending(c => priorCountries.Contains(c.Name))
.ThenBy(c => c.Name);
```

## 其他推荐答案

```var originalList = new List<string> { "B", "A", "E", "D", "C", "F" };
```

```var items = new List<string> { "E", "F" };
```

```items.AddRange(originalList.Except(items)
.OrderBy(q => q));
```

### 问题描述

I have a list of countries. I'd like to sort it alphabetically, except for two countries which I'd like to put first. Is there a simple way to modify

```from country in Countries
orderby country.Name
select country
```

to accomplish this?

## 推荐答案

Try this:

```var specialCountries = new[] { "America", "England" };

from country in Countries
orderby specialCountries.Contains(country.Name) descending, country.Name
select country
```

If this isn't LINQ-to-Objects, you might need to write it slightly differently for it to work, e.g. this might work

```from country in Countries
orderby (country.Name == "America" || country.Name == "England") descending, country.Name
select country
```

## 其他推荐答案

You can use this trick:

```var ordered = Countries.OrderByDescending(c => ConditionHere)
.ThenBy(c => c.Name);
```

for example:

```var priorCountries = new[]{ "Italy", "France" };
var ordered = Countries.OrderByDescending(c => priorCountries.Contains(c.Name))
.ThenBy(c => c.Name);
```

## 其他推荐答案

Your original list, which contains every country.

```var originalList = new List<string> { "B", "A", "E", "D", "C", "F" };
```

An exclusionary list, where you provide the order of items you'd like at the front.

```var items = new List<string> { "E", "F" };
```

```items.AddRange(originalList.Except(items)