FRangeSort

GitHubEdit on GitHub
packages@univerjs/sheets-sort

APIs

sort

Sorts the cells in the given range, by column(s) and order specified.

Signature

sort(column: SortColumnSpec | SortColumnSpec[]): FRange

Parameters

  • column (SortColumnSpec | SortColumnSpec[]) — The column index with order or an array of column indexes with order. The range first column index is 0.

Returns

  • (FRange) — The range itself for chaining.

Examples

const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getActiveSheet()
const fRange = fWorksheet.getRange('D1:G10')

// Sorts the range by the first column in ascending order.
fRange.sort(0)

// Sorts the range by the first column in descending order.
fRange.sort({ column: 0, ascending: false })

// Sorts the range by the first column in descending order and the second column in ascending order.
fRange.sort([{ column: 0, ascending: false }, 1])

Table of Contents

Capalyze