h2/src/main/org/h2/command/dml/Query.java
/**
     * Create a {@link SortOrder} object given the list of {@link SelectOrderBy}
     * objects. The expression list is extended if necessary.
     *
     * @param orderList a list of {@link SelectOrderBy} elements
     * @param expressionCount the number of columns in the query
     * @return the {@link SortOrder} object
     */
Create a  SortOrder object given the list of  SelectOrderBy
objects. The expression list is extended if necessary.

@param orderList a list of  SelectOrderBy elements
@param expressionCount the number of columns in the query
@return the  SortOrder object
Create a SortOrder object given the list of SelectOrderBy objects . The expression list is extended if necessary . @param orderList a list of SelectOrderBy elements @param expressionCount the number of columns in the query @return the SortOrder object
public SortOrder prepareOrder(ArrayList<SelectOrderBy> orderList, int expressionCount) {
        int size = orderList.size();
        int[] index = new int[size];
        int[] sortType = new int[size];
        for (int i = 0; i < size; i++) {
            SelectOrderBy o = orderList.get(i);
            int idx;
            boolean reverse = false;
            Expression expr = o.columnIndexExpr;
            Value v = expr.getValue(null);
            if (v == ValueNull.INSTANCE) {
                idx = 0;
            } else {
                idx = v.getInt();
                if (idx < 0) {
                    reverse = true;
                    idx = -idx;
                }
                idx -= 1;
                if (idx < 0 || idx >= expressionCount) {
                    throw DbException.get(ErrorCode.ORDER_BY_NOT_IN_RESULT, "" + (idx + 1));
                }
            }
            index[i] = idx;
            boolean desc = o.descending;
            if (reverse) {
                desc = !desc;
            }
            int type = desc ? SortOrder.DESCENDING : SortOrder.ASCENDING;
            if (o.nullsFirst) {
                type += SortOrder.NULLS_FIRST;
            } else if (o.nullsLast) {
                type += SortOrder.NULLS_LAST;
            }
            sortType[i] = type;
        }
        return new SortOrder(session.getDatabase(), index, sortType, orderList);
    }
public SortOrder prepareOrder ( ArrayList < SelectOrderBy > orderList , int expressionCount ) { int size = orderList . size ( ) ; int [ ] index = new int [ size ] ; int [ ] sortType = new int [ size ] ; for ( int i = 0 ; i < size ; i ++ ) { SelectOrderBy o = orderList . get ( i ) ; int idx ; boolean reverse = false ; Expression expr = o . columnIndexExpr ; Value v = expr . getValue ( null ) ; if ( v == ValueNull . INSTANCE ) { idx = 0 ; } else { idx = v . getInt ( ) ; if ( idx < 0 ) { reverse = true ; idx = - idx ; } idx -= 1 ; if ( idx < 0 || idx >= expressionCount ) { throw DbException . get ( ErrorCode . ORDER_BY_NOT_IN_RESULT , "" + ( idx + 1 ) ) ; } } index [ i ] = idx ; boolean desc = o . descending ; if ( reverse ) { desc = ! desc ; } int type = desc ? SortOrder . DESCENDING : SortOrder . ASCENDING ; if ( o . nullsFirst ) { type += SortOrder . NULLS_FIRST ; } else if ( o . nullsLast ) { type += SortOrder . NULLS_LAST ; } sortType [ i ] = type ; } return new SortOrder ( session . getDatabase ( ) , index , sortType , orderList ) ; }
Create a {@link SortOrder} object given the list of {@link SelectOrderBy}
 objects.
Create a { @link SortOrder } object given the list of { @link SelectOrderBy } objects .
// parameter not yet set - order by first column