Sorting

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 by executing the following code snippet.

var el = new Everlive('your-app-id');
var data = el.data('type-name');
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

You can read items sorted in descending order by a field by executing the following code snippet.

var el = new Everlive('your-app-id');
var data = el.data('type-name');
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));
    });

Sorting by 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.

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

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

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.