---
title: "My DataTables View is not sorting properly"
date: 2026-04-23
author: "GravityKit"
link: "https://www.gravitykit.com/docs/gravityview-pro/datatables/datatables-sorting/"
---

When creating or editing a View with [the DataTables Extension](https://www.gravitykit.com/products/datatables/), you can specify a field to sort by and a sort direction like so:

![Sort options with "Business Name" field selected and "ASC" ascending order chosen from dropdown menu](https://www.gravitykit.com/wp-content/uploads/2025/10/file-9V5tb3GIvO.jpg)
*Due to the way the DataTables Extension stores information using the browser, the View may retain a sort setting*
**To clear sorting, add `?cache` to the end of the View URL.** For example, `https://example.com/view/datatables-sort/` becomes `https://example.com/view/datatables-sort/?cache` — this will force the browser to reload the View without sorting.

You can also permanently fix this by adding the following code to your theme's functions.php file:

```

add_filter( 'gravityview_datatables_js_options', function( $dt_config, $view_id, $post ) {
    $dt_config['order'] = array();
    $dt_config['stateSave'] = false;
    return $dt_config;
}, 10, 3 );
```

```

add_filter( 'gravityview_datatables_js_options', function( $dt_config, $view_id, $post ) {
    $dt_config['order'] = array();
    $dt_config['stateSave'] = false;
    return $dt_config;
}, 10, 3 );
```

Read here how to add these code samples to your website: [Where to put code samples.](https://www.gravitykit.com/docs/gravityview/customizing-your-views/where-to-put-code-samples/)