SpreadJS 14
GC.Spread.Sheets Namespace / Worksheet type / sortRange Method
The index of the starting row of the block of cells to sort.
The index of the starting column of the block of cells to sort.
The number of rows in the block of cells.
The number of columns in the block of cells.
Set to true to sort by rows, and false to sort by columns.

The following settings are available:

sortInfo.index number type The index of the column or row on which to sort.
sortInfo.ascending boolean type Whether the sort order is ascending.
The index of the column or row on which to sort.
Whether the sort order is ascending When sort by value or custom sort.
Only support "top" and "bottom". color selected will group on top when order is "top".
The font color of sort.
The back color of sort. this paramter supports color string, gradient fill and pattern fill.
Whether the sort order is ascending. function (value1, value2) {return 0;}.
The sortOption indicate the detail performance of the sort.
The groupSort indicate the sort action with group, whether sort all the groups and its inner content.
Whether to ignore the hidden values and only sort visible values.
In This Topic
    sortRange Method
    In This Topic
    Sorts a range of cells in this sheet in the data model.
    Syntax
    var instance = new GC.Spread.Sheets.Worksheet(name);
    var value; // Type: boolean
    value = instance.sortRange(row,
                               column,
                               rowCount,
                               columnCount,
                               byRows,
                               sortInfo,
                               sortInfo.index,
                               sortInfo.ascending,
                               sortInfo.order,
                               sortInfo.fontColor,
                               sortInfo.backColor,
                               sortInfo.compareFunction,
                               sortOption,
                               sortOption.groupSort,
                               sortOption.ignoreHidden);
    function sortRange( 
       row : number,
       column : number,
       rowCount : number,
       columnCount : number,
       byRows : boolean,
       sortInfo : Object,
       sortInfo.index : number,
       sortInfo.ascending : boolean,
       sortInfo.order : string,
       sortInfo.fontColor : undefined,
       sortInfo.backColor : undefined,
       sortInfo.compareFunction : Function,
       sortOption : ISortOptions,
       sortOption.groupSort : groupSort,
       sortOption.ignoreHidden : boolean
    ) : boolean;

    Parameters

    row
    The index of the starting row of the block of cells to sort.
    column
    The index of the starting column of the block of cells to sort.
    rowCount
    The number of rows in the block of cells.
    columnCount
    The number of columns in the block of cells.
    byRows
    Set to true to sort by rows, and false to sort by columns.
    sortInfo

    The following settings are available:

    sortInfo.index number type The index of the column or row on which to sort.
    sortInfo.ascending boolean type Whether the sort order is ascending.
    sortInfo.index
    The index of the column or row on which to sort.
    sortInfo.ascending
    Whether the sort order is ascending When sort by value or custom sort.
    sortInfo.order
    Only support "top" and "bottom". color selected will group on top when order is "top".
    sortInfo.fontColor
    The font color of sort.
    sortInfo.backColor
    The back color of sort. this paramter supports color string, gradient fill and pattern fill.
    sortInfo.compareFunction
    Whether the sort order is ascending. function (value1, value2) {return 0;}.
    sortOption
    The sortOption indicate the detail performance of the sort.
    sortOption.groupSort
    The groupSort indicate the sort action with group, whether sort all the groups and its inner content.
    sortOption.ignoreHidden
    Whether to ignore the hidden values and only sort visible values.

    Return Value

    true if the data is sorted successfully; otherwise, false.
    Example
    This example sorts a range.
    sheet.setValue(0,0,"112");
    sheet.setValue(1,0,"10");
    sheet.setValue(2,0,"223");
    sheet.setValue(3,0,"20");
    sheet.setValue(4,0,"334");
    sheet.setValue(5,0,"30");
    sheet.sortRange(0, 0, 6, 1, true, [
                    {index:0, ascending:true}
                    ]);
    See Also