op.asc

op.asc(
   columndef as String
) as sortdef

Summary

This function sorts the rows by the values of the specified column in ascending order. The results are used by the prototype.orderBy function.

Parameters
columndef The column by which order the output.

Example

// Calculate the total expenses for each employee and return results in order of total
// expenses, lowest to highest.

const op = require('/MarkLogic/optic');

const employees = op.fromView('main', 'employees');
const expenses = op.fromView('main', 'expenses');
const totalexpenses  = op.col('totalexpenses');
const Plan =
employees.joinInner(expenses, op.on(employees.col('EmployeeID'), expenses.col('EmployeeID')))
   .groupBy(employees.col('EmployeeID'), ['FirstName', 'LastName', expenses.col('Category'),
    op.sum(totalexpenses, expenses.col('Amount'))])
   .orderBy(op.asc('totalexpenses'))
Plan.result();

  
Powered by MarkLogic Server | Terms of Use | Privacy Policy