Skip to content

Latest commit

 

History

History
73 lines (53 loc) · 1.84 KB

orderby-element-query.md

File metadata and controls

73 lines (53 loc) · 1.84 KB
title manager ms.date ms.audience ms.topic ms.localizationpriority api_name api_type ms.assetid description
OrderBy element (Query)
soliver
3/9/2015
Developer
reference
medium
Query schema
schema
7a659d08-9060-41d1-9a1c-e5a61376f3ba
In CAML, determines the sort order for a query. The OrderBy element contains a group of FieldRef elements.

OrderBy element (Query)

Applies to: SharePoint 2016 | SharePoint Foundation 2013 | SharePoint Online | SharePoint Server 2013

Determines the sort order for a query. The OrderBy element contains a group of FieldRef elements.

<OrderBy  Override = "TRUE" | "FALSE"  UseIndexForOrderBy = "TRUE" | "FALSE">
  <FieldRef
    Ascending = "TRUE" | "FALSE"
    Name = "Text" />
    ...
</OrderBy>

Elements and attributes

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute Description
Override
Optional Boolean.
UseIndexForOrderBy
Optional Boolean.

Child elements

Parent elements

Occurrences

  • Minimum: 0
  • Maximum: 1

Remarks

The order in which the fields appear is the order in which the fields are sorted. The value of the Ascending attribute in the FieldRef element determines whether to sort in ascending order.

Example

The following example sorts the fields first in ascending order by the Newcomers field, next in descending order by Years, and finally in ascending order by Location.

<OrderBy>
  <FieldRef Name="Newcomers"/>
  <FieldRef Name="Years" Ascending="FALSE"/>
  <FieldRef Name="Location"/>
</OrderBy>