> For the complete documentation index, see [llms.txt](https://docs.dikesoft.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.dikesoft.com/reference/dkgrid-api/dkgridsorting.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
