src/Query/Parser.php
public static function orderBy($field, $order)
    {
        if (!$order) {
            $order = 'DESC';
        }
        $order = strtoupper($order);
        if (!($order=='ASC' || $order=='DESC')) {
            throw new ClusterpointException("\"->order()\" function: ordering should be DESC or ASC.", 9002);
        }
        if (!(gettype($field)=="string" || $field instanceof Key || $field instanceof Raw)) {
            throw new ClusterpointException("\"->order()\" function: passed field selector is not in valid format.", 9002);
        }
        if ($field instanceof Key) {
            $field =  self::field("{$field}");
        }
        return "{$field} {$order}";
    }
public static function orderBy($field, $order)
    {
        if (!$order) {
            $order = 'DESC';
        }
        $order = strtoupper($order);
        if (!($order=='ASC' || $order=='DESC')) {
            throw new ClusterpointException("\"->order()\" function: ordering should be DESC or ASC.", 9002);
        }
        if (!(gettype($field)=="string" || $field instanceof Key || $field instanceof Raw)) {
            throw new ClusterpointException("\"->order()\" function: passed field selector is not in valid format.", 9002);
        }
        if ($field instanceof Key) {
            $field =  self::field("{$field}");
        }
        return "{$field} {$order}";
    }
Pass back ORDER BY Clause to append the scope.

@param  mixed  $field
@param  string $order
@return string