OrderBy()

noun

say it: “OR-der BY” /ˈɔːrdər baɪ/

The LINQ method that sorts items by a value, such as name or price.

What does OrderBy() do in C#?

OrderBy() — A LINQ operation that sorts a sequence by a selected key.

class NameSorter
{
    IEnumerable<string> Sort(IEnumerable<string> names)
    {
        return names.OrderBy(name => name);
    }
}

In a sentence

  • “OrderBy(p => p.ProductName) put the products in alphabetical order.”

Level: Freelancer · More C# terms at this level

Updated