# SearchResultsSorting

Location: [gRPC API](https://developer.m-files.com/APIs/gRPC-API/index.md) > [Reference](https://developer.m-files.com/APIs/gRPC-API/Reference/index.md) > [Messages](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/index.md)

HTML version: https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.SearchResultsSorting/

Struct for specifying sorting for search results.

Unset (no rules) keeps the default order: by relevance. A request the server cannot sort fails
with "The content can't be sorted across all pages." unless `options.allow_resorting_to_default_sort`
is set; then the results come in the default order and the response's search status flags have
`resorted_to_default_sort`. Sorting is not available with `SearchFlags.look_in_all_versions`.
When more objects match than the vault's sorting limit (20,000 by default), the same rule applies
(`resorted_to_default_sort_too_many_results`).

- **Full name:** `MFiles.SearchResultsSorting`
- **Proto file:** [`mfiles/structs.proto`](https://developer.m-files.com/APIs/gRPC-API/downloads/proto/mfiles/structs.proto)

<a id="fields"></a>

## Fields

| Field | Type | Number | Description |
|---|---|---|---|
| <a id="f-rules"></a>`rules` | [`SortRuleValueArray`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.SortRuleValueArray/index.md) | 1 | The sort rule. Exactly one rule is supported; more than one cannot be sorted. |
| <a id="f-options"></a>`options` | [`SortFlags`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.SortFlags/index.md) | 2 | Sort flags. Set `allow_resorting_to_default_sort` to get relevance order instead of an error when the rule cannot be applied. |

<a id="used-by-methods"></a>

## Used by methods

- [IRPCSearch.GetFolderContents](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSearch/GetFolderContents/index.md): Lists the contents of a view or a view level: subviews, grouping folders and objects.
- [IRPCSearch.GetFolderContentsOrDelta](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSearch/GetFolderContentsOrDelta/index.md): Gets the contents of the specified folder, or a delta that indicates changes to document vault data since the logical timestamp known by the caller.
- [IRPCSearch.SearchObjects](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSearch/SearchObjects/index.md): Searches the vault for objects that match the given conditions.

<a id="used-in-fields"></a>

## Used in fields

- [`SearchObjectsRequest.sorting`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSearch/SearchObjects/index.md#request): How to sort the results. Unset sorts by relevance. At most one rule; see [SearchResultsSorting](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.SearchResultsSorting/index.md).
- [`GetFolderContentsOrDeltaRequest.sorting`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSearch/GetFolderContentsOrDelta/index.md#request): If not empty, specifies how search results are being sorted.
- [`GetFolderContentsRequest.sorting`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSearch/GetFolderContents/index.md#request): If not empty, specifies how search results are being sorted.
