# DkGridSorting

## Generics

<mark style="color:green;">`<T>`</mark> represents the object's shape coming from the data source.&#x20;

<mark style="color:green;">`<R>`</mark> represents the column data type: <mark style="color:green;">`string`</mark>, <mark style="color:green;">`number`</mark>, <mark style="color:green;">`Date`</mark>, or <mark style="color:green;">`boolean`</mark>.

## Methods

| Method                 | Description                                                                                                                                                                                                                                                                                    |                                                                                                          |
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `sortBy()`             | <p>It sorts the DkGrid rows by the given column in the given direction.</p><p></p><p><strong>Params</strong>: </p><ol><li>column: <mark style="color:green;"><code>DkDataColumnDef\<T, R></code></mark>.</li><li>direction: <mark style="color:red;"><code>'asc'</code></mark>                 | <mark style="color:red;"><code>'desc'</code></mark></li></ol><p><strong>Return value</strong>: void.</p> |
| `isDkGridSortedBy()`   | <p>It evaluates if the DkGrid is sorted by the given column.</p><p></p><p><strong>Params</strong>: </p><ol><li>column: <mark style="color:green;"><code>DkDataColumnDef\<T, R></code></mark>.</li></ol><p><strong>Return</strong>: <mark style="color:green;"><code>boolean</code></mark>.</p> |                                                                                                          |
| `getCurrentSortable()` | <p>It returns the column and the direction of the sorting operation. Otherwise, it returns null.</p><p></p><p><strong>Params</strong>: None.</p><p><strong>Return</strong>: <mark style="color:green;"><code>DkColumnSorted\<T, R></code></mark>.</p>                                          |                                                                                                          |
| `clearSorting()`       | <p>It removes the current sorting operation.</p><p></p><p><strong>Params</strong>: None.</p><p><strong>Return</strong>: <mark style="color:green;"><code>void</code></mark>.</p>                                                                                                               |                                                                                                          |

## Events

| Event        | Description                                                                                                                                                                                                                                 |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `sortChange` | <p>It emits the column and the direction of the current sorting operation.</p><p></p><p><strong>Params</strong>: None.</p><p><strong>Return</strong>: <mark style="color:green;"><code>Observable\<DkColumnSortEvent\<T></code></mark>.</p> |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.dikesoft.com/reference/dkgrid-api/dkgridsorting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
