Progress will discontinue Telerik Platform on May 10th, 2018. Learn more

Sorting

Telerik Platform can return query results in sorted order: ascending or descending. All processing is performed on the server, saving you the additional operations on the client.

In this article:

Ascending

You can retrieve items sorted in ascending order by a field. The following example reads all items from Books sorted in ascending order by Author.

var el = new Everlive('your-app-id');
var data = el.data('Books');
var query = new Everlive.Query();
query.order('Author');
data.get(query) // filter
    .then(function(data){
        alert(JSON.stringify(data));
    },
    function(error){
        alert(JSON.stringify(error));
    });

Descending

To request sorting in descending order, use the orderDesc() Query function.

var el = new Everlive('your-app-id');
var data = el.data('Books');
var query = new Everlive.Query();
query.orderDesc('Author');
data.get(query) // filter
    .then(function(data){
        alert(JSON.stringify(data));
    },
    function(error){
        alert(JSON.stringify(error));
    });

Multiple Fields

When retrieving more elaborate data structures, you may need to sort by multiple fields. To do that, call the order() or orderDesc() methods multiple times in immediate succession. The first method call determines the primary sorting field, the second method call—the secondary sorting field, and so on. You can mix order() and orderDesc() in any order.

The following example reads all items from the Books content type and returns them sorted first by date of birth of the authors and then by author name.

var el = new Everlive('your-app-id');
var data = el.data('Books');

var query = new Everlive.Query();
query.order('DateOfBirth');
query.order('Author');

data.get(query) // filter
    .then(function(data){
        alert(JSON.stringify(data));
    },
    function(error){
        alert(JSON.stringify(error));
    });

See Also

Start a free trial Request a demo
Contact us: +1-888-365-2779
sales@telerik.com
Copyright © 2016-2017, Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.