diff --git a/Docs/SuperLinq.Docs/apidoc/SuperLinq.SuperEnumerable.OrderBy.md b/Docs/SuperLinq.Docs/apidoc/SuperLinq.SuperEnumerable.OrderBy.md
new file mode 100644
index 00000000..c8e323a9
--- /dev/null
+++ b/Docs/SuperLinq.Docs/apidoc/SuperLinq.SuperEnumerable.OrderBy.md
@@ -0,0 +1,27 @@
+---
+uid: SuperLinq.SuperEnumerable.OrderBy``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},SuperLinq.OrderByDirection)
+example: [*content]
+---
+The following code example demonstrates how to sort a sequence using `OrderBy` and `ThenBy`.
+[!code-csharp[](SuperLinq/OrderBy/OrderBy1.linq#L6-)]
+
+---
+uid: SuperLinq.SuperEnumerable.ThenBy``2(System.Linq.IOrderedEnumerable{``0},System.Func{``0,``1},SuperLinq.OrderByDirection)
+example: [*content]
+---
+The following code example demonstrates how to sort a sequence using `OrderBy` and `ThenBy`.
+[!code-csharp[](SuperLinq/OrderBy/OrderBy1.linq#L6-)]
+
+---
+uid: SuperLinq.SuperEnumerable.OrderBy``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Collections.Generic.IComparer{``1},SuperLinq.OrderByDirection)
+example: [*content]
+---
+The following code example demonstrates how to sort a sequence using `OrderBy` and `ThenBy`.
+[!code-csharp[](SuperLinq/OrderBy/OrderBy2.linq#L6-)]
+
+---
+uid: SuperLinq.SuperEnumerable.ThenBy``2(System.Linq.IOrderedEnumerable{``0},System.Func{``0,``1},System.Collections.Generic.IComparer{``1},SuperLinq.OrderByDirection)
+example: [*content]
+---
+The following code example demonstrates how to sort a sequence using `OrderBy` and `ThenBy`.
+[!code-csharp[](SuperLinq/OrderBy/OrderBy2.linq#L6-)]
diff --git a/Docs/SuperLinq.Docs/apidoc/SuperLinq/OrderBy/OrderBy1.linq b/Docs/SuperLinq.Docs/apidoc/SuperLinq/OrderBy/OrderBy1.linq
new file mode 100644
index 00000000..773194e5
--- /dev/null
+++ b/Docs/SuperLinq.Docs/apidoc/SuperLinq/OrderBy/OrderBy1.linq
@@ -0,0 +1,24 @@
+
+ SuperLinq
+ SuperLinq
+
+
+var fruits = new[]
+{
+ "grape", "passionfruit", "banana", "Mango",
+ "Orange", "raspberry", "apple", "blueberry",
+};
+
+// Sort the strings first by their length and then
+// alphabetically by passing the identity selector function.
+var result = fruits
+ .OrderBy(fruit => fruit.Length)
+ .ThenBy(fruit => fruit);
+
+Console.WriteLine(
+ "[" +
+ string.Join(", ", result) +
+ "]");
+
+// This code produces the following output:
+// [apple, grape, Mango, banana, Orange, blueberry, raspberry, passionfruit]
diff --git a/Docs/SuperLinq.Docs/apidoc/SuperLinq/OrderBy/OrderBy2.linq b/Docs/SuperLinq.Docs/apidoc/SuperLinq/OrderBy/OrderBy2.linq
new file mode 100644
index 00000000..b3a5cee7
--- /dev/null
+++ b/Docs/SuperLinq.Docs/apidoc/SuperLinq/OrderBy/OrderBy2.linq
@@ -0,0 +1,24 @@
+
+ SuperLinq
+ SuperLinq
+
+
+var fruits = new[]
+{
+ "grape", "passionfruit", "banana", "Mango",
+ "Orange", "raspberry", "apple", "blueberry",
+};
+
+// Sort the strings first by their length and then
+// alphabetically by passing the identity selector function.
+var result = fruits
+ .OrderBy(fruit => fruit.Length)
+ .ThenBy(fruit => fruit, StringComparer.Ordinal);
+
+Console.WriteLine(
+ "[" +
+ string.Join(", ", result) +
+ "]");
+
+// This code produces the following output:
+// [Mango, apple, grape, Orange, banana, blueberry, raspberry, passionfruit]
diff --git a/Source/SuperLinq/OrderBy.cs b/Source/SuperLinq/OrderBy.cs
index 6cff7448..ab25eaad 100644
--- a/Source/SuperLinq/OrderBy.cs
+++ b/Source/SuperLinq/OrderBy.cs
@@ -3,72 +3,156 @@
public static partial class SuperEnumerable
{
///
- /// Sorts the elements of a sequence in a particular direction (ascending, descending) according to a key
+ /// Sorts the elements of a sequence in a particular direction (ascending, descending) according to a key
///
- /// The type of the elements in the source sequence
- /// The type of the key used to order elements
- /// The sequence to order
- /// A key selector function
- /// A direction in which to order the elements (ascending, descending)
- /// An ordered copy of the source sequence
-
+ ///
+ /// The type of the elements in the source sequence
+ ///
+ ///
+ /// The type of the key used to order elements
+ ///
+ ///
+ /// The sequence to order
+ ///
+ ///
+ /// A key selector function
+ ///
+ ///
+ /// A direction in which to order the elements (ascending, descending)
+ ///
+ ///
+ /// or is .
+ ///
+ ///
+ /// An ordered copy of the source sequence
+ ///
+ ///
+ ///
+ /// This method is implemented by using deferred execution. However, will be consumed
+ /// in it's entirety immediately when first element of the returned sequence is consumed.
+ ///
+ ///
public static IOrderedEnumerable OrderBy(this IEnumerable source, Func keySelector, OrderByDirection direction)
{
return OrderBy(source, keySelector, null, direction);
}
///
- /// Sorts the elements of a sequence in a particular direction (ascending, descending) according to a key
+ /// Sorts the elements of a sequence in a particular direction (ascending, descending) according to a key
///
- /// The type of the elements in the source sequence
- /// The type of the key used to order elements
- /// The sequence to order
- /// A key selector function
- /// A direction in which to order the elements (ascending, descending)
- /// A comparer used to define the semantics of element comparison
- /// An ordered copy of the source sequence
-
+ ///
+ /// The type of the elements in the source sequence
+ ///
+ ///
+ /// The type of the key used to order elements
+ ///
+ ///
+ /// The sequence to order
+ ///
+ ///
+ /// A key selector function
+ ///
+ ///
+ /// An to compare keys
+ ///
+ ///
+ /// A direction in which to order the elements (ascending, descending)
+ ///
+ ///
+ /// or is .
+ ///
+ ///
+ /// An ordered copy of the source sequence
+ ///
+ ///
+ ///
+ /// This method is implemented by using deferred execution. However, will be consumed
+ /// in it's entirety immediately when first element of the returned sequence is consumed.
+ ///
+ ///
public static IOrderedEnumerable OrderBy(this IEnumerable source, Func keySelector, IComparer? comparer, OrderByDirection direction)
{
Guard.IsNotNull(source);
Guard.IsNotNull(keySelector);
return direction == OrderByDirection.Ascending
- ? source.OrderBy(keySelector, comparer)
- : source.OrderByDescending(keySelector, comparer);
+ ? source.OrderBy(keySelector, comparer)
+ : source.OrderByDescending(keySelector, comparer);
}
///
- /// Performs a subsequent ordering of elements in a sequence in a particular direction (ascending, descending) according to a key
+ /// Performs a subsequent ordering of elements of a sequence in a particular direction (ascending, descending) according to a key
///
- /// The type of the elements in the source sequence
- /// The type of the key used to order elements
- /// The sequence to order
- /// A key selector function
- /// A direction in which to order the elements (ascending, descending)
- /// An ordered copy of the source sequence
-
+ ///
+ /// The type of the elements in the source sequence
+ ///
+ ///
+ /// The type of the key used to order elements
+ ///
+ ///
+ /// The sequence to order
+ ///
+ ///
+ /// A key selector function
+ ///
+ ///
+ /// A direction in which to order the elements (ascending, descending)
+ ///
+ ///
+ /// or is .
+ ///
+ ///
+ /// An ordered copy of the source sequence
+ ///
+ ///
+ ///
+ /// This method is implemented by using deferred execution. However, will be consumed
+ /// in it's entirety immediately when first element of the returned sequence is consumed.
+ ///
+ ///
public static IOrderedEnumerable ThenBy(this IOrderedEnumerable source, Func keySelector, OrderByDirection direction)
{
return ThenBy(source, keySelector, null, direction);
}
///
- /// Performs a subsequent ordering of elements in a sequence in a particular direction (ascending, descending) according to a key
+ /// Performs a subsequent ordering of elements of a sequence in a particular direction (ascending, descending) according to a key
///
- /// The type of the elements in the source sequence
- /// The type of the key used to order elements
- /// The sequence to order
- /// A key selector function
- /// A direction in which to order the elements (ascending, descending)
- /// A comparer used to define the semantics of element comparison
- /// An ordered copy of the source sequence
-
+ ///
+ /// The type of the elements in the source sequence
+ ///
+ ///
+ /// The type of the key used to order elements
+ ///
+ ///
+ /// The sequence to order
+ ///
+ ///
+ /// A key selector function
+ ///
+ ///
+ /// An to compare keys
+ ///
+ ///
+ /// A direction in which to order the elements (ascending, descending)
+ ///
+ ///
+ /// or is .
+ ///
+ ///
+ /// An ordered copy of the source sequence
+ ///
+ ///
+ ///
+ /// This method is implemented by using deferred execution. However, will be consumed
+ /// in it's entirety immediately when first element of the returned sequence is consumed.
+ ///
+ ///
public static IOrderedEnumerable ThenBy(this IOrderedEnumerable source, Func keySelector, IComparer? comparer, OrderByDirection direction)
{
Guard.IsNotNull(source);
Guard.IsNotNull(keySelector);
return direction == OrderByDirection.Ascending
- ? source.ThenBy(keySelector, comparer)
- : source.ThenByDescending(keySelector, comparer);
+ ? source.ThenBy(keySelector, comparer)
+ : source.ThenByDescending(keySelector, comparer);
}
}