我有一个要求,我要从SQL数据库中填充此列表,该列表具有一个布尔字段,现在必须根据此字段对列表进行排序,但不应在已排序的列表中进行默认排序结果。
class Program
{
static void Main(string[] args)
{
List<NP> np=new List<NP>()
{
new NP()
{
IsSelected = true,
Desc="DN"
},
new NP()
{
IsSelected = false,
Desc="JL"
},
new NP()
{
IsSelected = true,
Desc="ON"
},
new NP()
{
IsSelected = true,
Desc="PR"
},
new NP()
{
IsSelected = false,
Desc="PS"
},
new NP()
{
IsSelected = true,
Desc="RPA"
},
};
List<NP> orNP = np.OrderByDescending(x => x.IsSelected).ToList();
Console.ReadLine();
}
}
public class NP
{
public bool IsSelected { get; set; }
public string Desc { get; set; }
}
但是我想按此顺序显示: * 上 * RPA *公关 * DN * PS * JL