Enum SortOrder
- Namespace
- Cuemon
- Assembly
- Cuemon.Core.dll
Specifies the direction of a sort operation.
public enum SortOrder
Fields
Ascending = 0Sorts in ascending order.
Descending = 1Sorts in descending order.
Unspecified = 2No sort order is specified, meaning the default sorting is used.
Examples
The following example demonstrates how to use the
using System;
using System.Collections.Generic;
using Cuemon;
namespace Contoso.Search;
public sealed class SortOrderExample
{
public static void Run()
{
var names = new List<string> { "Charlie", "Alice", "Bob" };
Apply(names, SortOrder.Ascending);
Console.WriteLine(string.Join(", ", names));
Apply(names, SortOrder.Descending);
Console.WriteLine(string.Join(", ", names));
}
private static void Apply(List<string> names, SortOrder sortOrder)
{
names.Sort((left, right) =>
{
int result = string.Compare(left, right, StringComparison.Ordinal);
return sortOrder == SortOrder.Descending ? -result : result;
});
}
}