Qu

xlsx.sort_range

Builtin index · File I/O

xlsx.sort_range(wb, sheet, range, by, [desc=false], [header=false])

Input: wb, sheet, range, by, desc, header · Output: no output

What it is

Sorts the rows of range by one or more key columns: by="C" is a column of the sheet, by=2 the second column of the range, a list (by=["B", "A"]) breaks ties by the next key, and desc is one flag or one per key. Whole rows move -- values, formulas (relative references follow the row, as in Excel's sort) and formatting -- and the sort is stable. header=true keeps the first row on top (the default is false: nothing is guessed). Order as Excel's: numbers, then text (case-insensitive), then true/false; empty cells last in either direction. A key cell holding a formula with no stored value (never calculated) is an error, and so is a range holding merged cells.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
xlsx.sort_range(wb, sheet, range, by, [desc=false], [header=false])
wb —not documented yet
sheet —Sorts the rows of range by one or more key columns: by="C" is a column of the sheet, by=2 the second column of the range, a list (by=["B", "A"]) breaks ties by the next key, and desc is one flag or one per key.
range —Sorts the rows of range by one or more key columns: by="C" is a column of the sheet, by=2 the second column of the range, a list (by=["B", "A"]) breaks ties by the next key, and desc is one flag or one per key.
by —Sorts the rows of range by one or more key columns: by="C" is a column of the sheet, by=2 the second column of the range, a list (by=["B", "A"]) breaks ties by the next key, and desc is one flag or one per key.
desc optional (default false)Sorts the rows of range by one or more key columns: by="C" is a column of the sheet, by=2 the second column of the range, a list (by=["B", "A"]) breaks ties by the next key, and desc is one flag or one per key.
header optional (default false)header=true keeps the first row on top (the default is false: nothing is guessed).
no outputWhole rows move -- values, formulas (relative references follow the row, as in Excel's sort) and formatting -- and the sort is stable. Order as Excel's: numbers, then text (case-insensitive), then true/false; empty cells last in either direction.

Examples

No documentation example calls this form yet. The File I/O chapter is where one belongs.