Scoped GlideAggregate - orderByAggregate(String agg, String fieldName)

Orders the aggregates based on the specified aggregate and field.

Table 1. Parameters
Name Type Description
agg String Type of aggregation.
fieldName String Name of the field to aggregate.
Table 2. Returns
Type Description
void

ga.addAggregate(‘COUNT’, ‘category’);
 
ga.orderByAggregate('count', 'category');
 
ga.query();
 
while(ga.next()) {
  gs.info(‘Category ’ + ga.category + ‘ ‘ + ga.getAggregate(‘COUNT’, ‘category’));
  }

Output:

Category inquiry 18
Category software 11
Category hardware 7
Category network 5
Category request 5
Category  4
Category database 2