## org.h2.result
Class SortOrder

    java.lang.Object
      org.h2.result.SortOrder

All Implemented Interfaces:
  java.util.Comparator<Value[]>

    public class SortOrder

extends java.lang.Object
implements java.util.Comparator<Value[]>

A sort order represents an ORDER BY clause in a query.

Field Summary
`static int` `ASCENDING` This bit mask means the values should be sorted in ascending order.
`static int` `DESCENDING` This bit mask means the values should be sorted in descending order.
`static int` `NULLS_FIRST` This bit mask means NULLs should be sorted before other data, no matter if ascending or descending order is used.
`static int` `NULLS_LAST` This bit mask means NULLs should be sorted after other data, no matter if ascending or descending order is used.

Constructor Summary
`SortOrder(Database database, int[] index, int[] sortType)` Construct a new sort order object.

Method Summary
`int` `compare(Value[] a, Value[] b)` Compare two expression lists.
`static int` `compareNull(boolean aNull, boolean bNull, int sortType)` Compare two expressions where one of them is NULL.
`int[]` `getIndexes()` Get the column index list.
`int[]` `getSortTypes()` Get the sort order bit masks.
`java.lang.String` `getSQL(Expression[] list, int visible)` Create the SQL snippet that describes this sort order.
`void` `sort(java.util.ArrayList<Value[]> rows)` Sort a list of rows.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface java.util.Comparator
`equals`

Field Detail

### ASCENDING

    public static final int ASCENDING

  This bit mask means the values should be sorted in ascending order.

  See Also:
    Constant Field Values

### DESCENDING

    public static final int DESCENDING

  This bit mask means the values should be sorted in descending order.

  See Also:
    Constant Field Values

### NULLS_FIRST

    public static final int NULLS_FIRST

  This bit mask means NULLs should be sorted before other data, no matter if ascending or descending order is used.

  See Also:
    Constant Field Values

### NULLS_LAST

    public static final int NULLS_LAST

  This bit mask means NULLs should be sorted after other data, no matter if ascending or descending order is used.

  See Also:
    Constant Field Values

Constructor Detail

### SortOrder

    public SortOrder(Database database,
                     int[] index,
                     int[] sortType)

  Construct a new sort order object.

  Parameters:
    `database` - the database
    `index` - the column index list
    `sortType` - the sort order bit masks

Method Detail

### getSQL

    public java.lang.String getSQL(Expression[] list,
                                   int visible)

  Create the SQL snippet that describes this sort order. This is the SQL snippet that usually appears after the ORDER BY clause.

  Parameters:
    `list` - the expression list
    `visible` - the number of columns in the select list
  Returns:
    the SQL snippet

### compareNull

    public static int compareNull(boolean aNull,
                                  boolean bNull,
                                  int sortType)

  Compare two expressions where one of them is NULL.

  Parameters:
    `aNull` - whether the first expression is null
    `bNull` - whether the second expression is null
    `sortType` - the sort bit mask to use
  Returns:
    the result of the comparison (-1 meaning the first expression should appear before the second, 0 if they are equal)

### compare

    public int compare(Value[] a,
                       Value[] b)

  Compare two expression lists.

  Specified by:
    `compare` in interface `java.util.Comparator<Value[]>`
  Parameters:
    `a` - the first expression list
    `b` - the second expression list
  Returns:
    the result of the comparison

### sort

    public void sort(java.util.ArrayList<Value[]> rows)

  Sort a list of rows.

  Parameters:
    `rows` - the list of rows

### getIndexes

    public int[] getIndexes()

  Get the column index list.

  Returns:
    the list

### getSortTypes

    public int[] getSortTypes()

  Get the sort order bit masks.

  Returns:
    the list