IOrderedEnumerable(Of TElement) Interface
Represents a sorted sequence.
Assembly: System.Core (in System.Core.dll)
This type is enumerable because it inherits from IEnumerable(Of T).
The extension methods ThenBy and ThenByDescending operate on objects of type IOrderedEnumerable(Of TElement). An object of type IOrderedEnumerable(Of TElement) can be obtained by calling one of the primary sort methods, OrderBy or OrderByDescending, which return an IOrderedEnumerable(Of TElement). ThenBy and ThenByDescending, the subordinate sort methods, in turn also return an object of type IOrderedEnumerable(Of TElement). This design allows for any number of consecutive calls to ThenBy or ThenByDescending, where each call performs a subordinate ordering on the sorted data returned from the previous call.
The following example demonstrates how to perform a primary and secondary ordering on an array of strings. It also demonstrates that the resulting IOrderedEnumerable(Of TElement) is enumerable.
' Create an array of strings to sort. Dim fruits() As String = _ {"apricot", "orange", "banana", "mango", "apple", "grape", "strawberry"} ' Sort the strings first by their length and then alphabetically by passing the identity selector function. Dim sortedFruits1 As IOrderedEnumerable(Of String) = _ fruits.OrderBy(Function(ByVal fruit) fruit.Length).ThenBy(Function(ByVal fruit) fruit) Dim output As New System.Text.StringBuilder ' Output the resulting sequence of strings. For Each fruit As String In sortedFruits1 output.AppendLine(fruit) Next ' Display the results. MsgBox(output.ToString()) ' This code produces the following output: ' ' apple ' grape ' mango ' banana ' orange ' apricot ' strawberry
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.