New to Kendo UI for jQueryStart a free 30-day trial

Sort

methods

Gets or sets the sort order which will be applied over the data items.

Parameters:valueObject|Array

The sort configuration. Accepts the same values as the sort option.

Returns:Array

—The current sort configuration. Returns undefined instead of an empty array if the DataSource instance has not performed any sorting so far.

<script>
var dataSource = new kendo.data.DataSource({
  data: [
    { name: "Jane Doe", age: 30 },
    { name: "John Doe", age: 33 }
  ]
});
dataSource.sort({ field: "age", dir: "desc" });
var view = dataSource.view();
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(view[0].name); // displays "John Doe"
</script>
<script>
var dataSource = new kendo.data.DataSource({
  data: [
    { name: "Jane Doe", age: 30 },
    { name: "John Doe", age: 33 }
  ],
  sort: { field: "age", dir: "desc" }
});
var sort = dataSource.sort();
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(sort.length);   // displays "1"
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(sort[0].field); // displays "age"
</script>
Not finding the help you need?
Contact Support