Edit this page

sort

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

Parameters

value Object |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.

Example - sort the data items

<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();
console.log(view[0].name); // displays "John Doe"
</script>

Example - get the sort configuration

<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();
console.log(sort.length);   // displays "1"
console.log(sort[0].field); // displays "age"
</script>
Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy