Linq-sorting-operators
提供:Dev Guides
LINQの演算子の並べ替え
ソート操作を使用すると、単一または複数の属性に基づいてシーケンスの要素を並べることができます。
Operator | Description | C# Query Expression Syntax | VB Query Expression Syntax |
---|---|---|---|
OrderBy | The operator sort values in an ascending order | orderby | Order By |
OrderByDescending | The operator sort values in a descending order | orderby … descending | Order By … Descending |
ThenBy | Executes a secondary sorting in an ascending order | orderby …, … | Order By …, … |
ThenByDescending | Executes a secondary sorting in a descending order | orderby …, … descending | Order By …, … Descending |
Reverse | Performs a reversal of the order of the elements in a collection | Not Applicable | Not Applicable |
OrderBy、OrderByDescendingの例-クエリ式
C#
VB
C#またはVBの上記のコードがコンパイルされて実行されると、次の結果が生成されます-
ThenbyおよびThenbyDescending演算子では、同じ構文を適用でき、並べ替え順序は複数の列に依存します。 優先順位は、最初に維持される列になります。