You are currently browsing legacy 3.0 version of documentation. Click here to switch to the newest 4.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Sorting

Indexed values are sorted lexicographically, but sorting is not applied until you request it by using one of the appropriate methods:

OrderBy

To get ordered results we need to indicate a field name to sort by:

List<FileHeader> results = await session.Query()
							.OrderBy(x => x.Name)
							.ToListAsync();

OrderByDescending

You can also retrieve results in descending order:

List<FileHeader> results = await session.Query()
							.OrderByDescending("Owner") // order descending by "Owner" metadata 
							.ToListAsync();