# CustomField Sort Clause

The [`CustomField` Sort Clause](https://doc.ibexa.co/en/latest/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-Query-SortClause-CustomField.html) sorts search results by raw search index fields.

## Arguments

- `field` - string representing the search index field name
- (optional) `sortDirection` - Query or LocationQuery constant, either `Query::SORT_ASC` or `Query::SORT_DESC`

## Limitations

Caution

To keep your project search engine independent, don't use the `CustomField` Sort Clause in production code. Valid use cases are: testing, or temporary (one-off) tools.

The `CustomField` Sort Clause isn't available in [Repository filtering](https://doc.ibexa.co/en/latest/search/search_api/#repository-filtering).

## Example

```
$query = new LocationQuery();
$query->sortClauses = [new SortClause\CustomField('my_custom_field_s')];
```
