|
3 | 3 | public static partial class SuperEnumerable
|
4 | 4 | {
|
5 | 5 | /// <summary>
|
6 |
| - /// Sorts the elements of a sequence in a particular direction (ascending, descending) according to a key |
| 6 | + /// Sorts the elements of a sequence in a particular direction (ascending, descending) according to a key |
7 | 7 | /// </summary>
|
8 |
| - /// <typeparam name="T">The type of the elements in the source sequence</typeparam> |
9 |
| - /// <typeparam name="TKey">The type of the key used to order elements</typeparam> |
10 |
| - /// <param name="source">The sequence to order</param> |
11 |
| - /// <param name="keySelector">A key selector function</param> |
12 |
| - /// <param name="direction">A direction in which to order the elements (ascending, descending)</param> |
13 |
| - /// <returns>An ordered copy of the source sequence</returns> |
14 |
| - |
| 8 | + /// <typeparam name="T"> |
| 9 | + /// The type of the elements in the source sequence |
| 10 | + /// </typeparam> |
| 11 | + /// <typeparam name="TKey"> |
| 12 | + /// The type of the key used to order elements |
| 13 | + /// </typeparam> |
| 14 | + /// <param name="source"> |
| 15 | + /// The sequence to order |
| 16 | + /// </param> |
| 17 | + /// <param name="keySelector"> |
| 18 | + /// A key selector function |
| 19 | + /// </param> |
| 20 | + /// <param name="direction"> |
| 21 | + /// A direction in which to order the elements (ascending, descending) |
| 22 | + /// </param> |
| 23 | + /// <exception cref="ArgumentNullException"> |
| 24 | + /// <paramref name="source"/> or <paramref name="keySelector"/> is <see langword="null"/>. |
| 25 | + /// </exception> |
| 26 | + /// <returns> |
| 27 | + /// An ordered copy of the source sequence |
| 28 | + /// </returns> |
| 29 | + /// <remarks> |
| 30 | + /// <para> |
| 31 | + /// This method is implemented by using deferred execution. However, <paramref name="source"/> will be consumed |
| 32 | + /// in it's entirety immediately when first element of the returned sequence is consumed. |
| 33 | + /// </para> |
| 34 | + /// </remarks> |
15 | 35 | public static IOrderedEnumerable<T> OrderBy<T, TKey>(this IEnumerable<T> source, Func<T, TKey> keySelector, OrderByDirection direction)
|
16 | 36 | {
|
17 | 37 | return OrderBy(source, keySelector, null, direction);
|
18 | 38 | }
|
19 | 39 |
|
20 | 40 | /// <summary>
|
21 |
| - /// Sorts the elements of a sequence in a particular direction (ascending, descending) according to a key |
| 41 | + /// Sorts the elements of a sequence in a particular direction (ascending, descending) according to a key |
22 | 42 | /// </summary>
|
23 |
| - /// <typeparam name="T">The type of the elements in the source sequence</typeparam> |
24 |
| - /// <typeparam name="TKey">The type of the key used to order elements</typeparam> |
25 |
| - /// <param name="source">The sequence to order</param> |
26 |
| - /// <param name="keySelector">A key selector function</param> |
27 |
| - /// <param name="direction">A direction in which to order the elements (ascending, descending)</param> |
28 |
| - /// <param name="comparer">A comparer used to define the semantics of element comparison</param> |
29 |
| - /// <returns>An ordered copy of the source sequence</returns> |
30 |
| - |
| 43 | + /// <typeparam name="T"> |
| 44 | + /// The type of the elements in the source sequence |
| 45 | + /// </typeparam> |
| 46 | + /// <typeparam name="TKey"> |
| 47 | + /// The type of the key used to order elements |
| 48 | + /// </typeparam> |
| 49 | + /// <param name="source"> |
| 50 | + /// The sequence to order |
| 51 | + /// </param> |
| 52 | + /// <param name="keySelector"> |
| 53 | + /// A key selector function |
| 54 | + /// </param> |
| 55 | + /// <param name="comparer"> |
| 56 | + /// An <see cref="IComparer{T}"/> to compare keys |
| 57 | + /// </param> |
| 58 | + /// <param name="direction"> |
| 59 | + /// A direction in which to order the elements (ascending, descending) |
| 60 | + /// </param> |
| 61 | + /// <exception cref="ArgumentNullException"> |
| 62 | + /// <paramref name="source"/> or <paramref name="keySelector"/> is <see langword="null"/>. |
| 63 | + /// </exception> |
| 64 | + /// <returns> |
| 65 | + /// An ordered copy of the source sequence |
| 66 | + /// </returns> |
| 67 | + /// <remarks> |
| 68 | + /// <para> |
| 69 | + /// This method is implemented by using deferred execution. However, <paramref name="source"/> will be consumed |
| 70 | + /// in it's entirety immediately when first element of the returned sequence is consumed. |
| 71 | + /// </para> |
| 72 | + /// </remarks> |
31 | 73 | public static IOrderedEnumerable<T> OrderBy<T, TKey>(this IEnumerable<T> source, Func<T, TKey> keySelector, IComparer<TKey>? comparer, OrderByDirection direction)
|
32 | 74 | {
|
33 | 75 | Guard.IsNotNull(source);
|
34 | 76 | Guard.IsNotNull(keySelector);
|
35 | 77 | return direction == OrderByDirection.Ascending
|
36 |
| - ? source.OrderBy(keySelector, comparer) |
37 |
| - : source.OrderByDescending(keySelector, comparer); |
| 78 | + ? source.OrderBy(keySelector, comparer) |
| 79 | + : source.OrderByDescending(keySelector, comparer); |
38 | 80 | }
|
39 | 81 |
|
40 | 82 | /// <summary>
|
41 |
| - /// Performs a subsequent ordering of elements in a sequence in a particular direction (ascending, descending) according to a key |
| 83 | + /// Performs a subsequent ordering of elements of a sequence in a particular direction (ascending, descending) according to a key |
42 | 84 | /// </summary>
|
43 |
| - /// <typeparam name="T">The type of the elements in the source sequence</typeparam> |
44 |
| - /// <typeparam name="TKey">The type of the key used to order elements</typeparam> |
45 |
| - /// <param name="source">The sequence to order</param> |
46 |
| - /// <param name="keySelector">A key selector function</param> |
47 |
| - /// <param name="direction">A direction in which to order the elements (ascending, descending)</param> |
48 |
| - /// <returns>An ordered copy of the source sequence</returns> |
49 |
| - |
| 85 | + /// <typeparam name="T"> |
| 86 | + /// The type of the elements in the source sequence |
| 87 | + /// </typeparam> |
| 88 | + /// <typeparam name="TKey"> |
| 89 | + /// The type of the key used to order elements |
| 90 | + /// </typeparam> |
| 91 | + /// <param name="source"> |
| 92 | + /// The sequence to order |
| 93 | + /// </param> |
| 94 | + /// <param name="keySelector"> |
| 95 | + /// A key selector function |
| 96 | + /// </param> |
| 97 | + /// <param name="direction"> |
| 98 | + /// A direction in which to order the elements (ascending, descending) |
| 99 | + /// </param> |
| 100 | + /// <exception cref="ArgumentNullException"> |
| 101 | + /// <paramref name="source"/> or <paramref name="keySelector"/> is <see langword="null"/>. |
| 102 | + /// </exception> |
| 103 | + /// <returns> |
| 104 | + /// An ordered copy of the source sequence |
| 105 | + /// </returns> |
| 106 | + /// <remarks> |
| 107 | + /// <para> |
| 108 | + /// This method is implemented by using deferred execution. However, <paramref name="source"/> will be consumed |
| 109 | + /// in it's entirety immediately when first element of the returned sequence is consumed. |
| 110 | + /// </para> |
| 111 | + /// </remarks> |
50 | 112 | public static IOrderedEnumerable<T> ThenBy<T, TKey>(this IOrderedEnumerable<T> source, Func<T, TKey> keySelector, OrderByDirection direction)
|
51 | 113 | {
|
52 | 114 | return ThenBy(source, keySelector, null, direction);
|
53 | 115 | }
|
54 | 116 |
|
55 | 117 | /// <summary>
|
56 |
| - /// Performs a subsequent ordering of elements in a sequence in a particular direction (ascending, descending) according to a key |
| 118 | + /// Performs a subsequent ordering of elements of a sequence in a particular direction (ascending, descending) according to a key |
57 | 119 | /// </summary>
|
58 |
| - /// <typeparam name="T">The type of the elements in the source sequence</typeparam> |
59 |
| - /// <typeparam name="TKey">The type of the key used to order elements</typeparam> |
60 |
| - /// <param name="source">The sequence to order</param> |
61 |
| - /// <param name="keySelector">A key selector function</param> |
62 |
| - /// <param name="direction">A direction in which to order the elements (ascending, descending)</param> |
63 |
| - /// <param name="comparer">A comparer used to define the semantics of element comparison</param> |
64 |
| - /// <returns>An ordered copy of the source sequence</returns> |
65 |
| - |
| 120 | + /// <typeparam name="T"> |
| 121 | + /// The type of the elements in the source sequence |
| 122 | + /// </typeparam> |
| 123 | + /// <typeparam name="TKey"> |
| 124 | + /// The type of the key used to order elements |
| 125 | + /// </typeparam> |
| 126 | + /// <param name="source"> |
| 127 | + /// The sequence to order |
| 128 | + /// </param> |
| 129 | + /// <param name="keySelector"> |
| 130 | + /// A key selector function |
| 131 | + /// </param> |
| 132 | + /// <param name="comparer"> |
| 133 | + /// An <see cref="IComparer{T}"/> to compare keys |
| 134 | + /// </param> |
| 135 | + /// <param name="direction"> |
| 136 | + /// A direction in which to order the elements (ascending, descending) |
| 137 | + /// </param> |
| 138 | + /// <exception cref="ArgumentNullException"> |
| 139 | + /// <paramref name="source"/> or <paramref name="keySelector"/> is <see langword="null"/>. |
| 140 | + /// </exception> |
| 141 | + /// <returns> |
| 142 | + /// An ordered copy of the source sequence |
| 143 | + /// </returns> |
| 144 | + /// <remarks> |
| 145 | + /// <para> |
| 146 | + /// This method is implemented by using deferred execution. However, <paramref name="source"/> will be consumed |
| 147 | + /// in it's entirety immediately when first element of the returned sequence is consumed. |
| 148 | + /// </para> |
| 149 | + /// </remarks> |
66 | 150 | public static IOrderedEnumerable<T> ThenBy<T, TKey>(this IOrderedEnumerable<T> source, Func<T, TKey> keySelector, IComparer<TKey>? comparer, OrderByDirection direction)
|
67 | 151 | {
|
68 | 152 | Guard.IsNotNull(source);
|
69 | 153 | Guard.IsNotNull(keySelector);
|
70 | 154 | return direction == OrderByDirection.Ascending
|
71 |
| - ? source.ThenBy(keySelector, comparer) |
72 |
| - : source.ThenByDescending(keySelector, comparer); |
| 155 | + ? source.ThenBy(keySelector, comparer) |
| 156 | + : source.ThenByDescending(keySelector, comparer); |
73 | 157 | }
|
74 | 158 | }
|
0 commit comments