Scoped GlideRecord - orderBy(String name)

Specifies an orderBy column.

Call this method more than once to order by multiple columns. Results are arranged in ascending order, see orderByDesc(String name) to arrange records in descending order.

Table 1. Parameters
Name Type Description
name String The column name used to order the records in this GlideRecord object.
Table 2. Returns
Type Description
void
var queryString = "priority=2"; 
var gr = new GlideRecord('incident'); 
gr.orderBy('short_description'); // Ascending Order
gr.addEncodedQuery(queryString); 
gr.query(); 
while (gr.next()) { 
    gs.info(gr.short_description); 
}

Output: