K
K
KaRaMiD2022-03-24 17:46:10
C++ / C#
KaRaMiD, 2022-03-24 17:46:10

How to sort List elements by bool variable?

I have a List and I need to sort from there elements that have a bool variable value. How to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2022-03-24
@vabka

Via OrderBy or OrderByDescending

using System.Collections.Generic.Linq;

var sortedList = list.OrderBy(x => x.SomeBoolField).ToList();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question