Table of Contents

Method OrderBy

Namespace
MongoDB.Driver.Linq
Assembly
MongoDB.Driver.dll

OrderBy<TSource, TKey>(IMongoQueryable<TSource>, Expression<Func<TSource, TKey>>)

Sorts the elements of a sequence in ascending order according to a key.

public static IOrderedMongoQueryable<TSource> OrderBy<TSource, TKey>(this IMongoQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector)

Parameters

source IMongoQueryable<TSource>

A sequence of values to order.

keySelector Expression<Func<TSource, TKey>>

A function to extract a key from an element.

Returns

IOrderedMongoQueryable<TSource>

An IOrderedMongoQueryable<T> whose elements are sorted according to a key.

Type Parameters

TSource

The type of the elements of source.

TKey

The type of the key returned by the function that is represented by keySelector.