In this recipe, we will enable column sorting. This will allow the user to click on the header cells of the table to sort the entire table alphabetically or numerically by the contents of that column. Clicking once will sort ascending, and clicking a second time will sort descending. Subsequent clicks will toggle between these two states.
Open the datatable.js
file for editing. We will modify the column definitions to allow sorting.
Modify the column definition as follows:
var columns = [ { key: "chapter", label: "Chapter No.", formatter: "number", sortable: true { key: "title", label: "Title", formatter: "string", sortable: true } ];