SORT Function in LibreOffice Calc — Tested Examples

Lookup Intermediate LibreOffice Calc

An explanation of LibreOffice Calc SORT, including tested formulas, examples, expected results and common mistakes.

Tested: Examples checked in LibreOffice Calc 25.2.3.2. What this means

Sorts the contents of a range or array. In the example B1:B5 contains 10,20,30,40,50. Sorted descending, the first value is 50; sorted ascending, it is 10.

Syntax and arguments

=SORT(Range; Sort_index; Sort_order; By_col)

LibreOffice Calc formulas generally separate arguments with semicolons (;).

Argument Explanation
Range The range, or array to sort.
Sort index A number indicating the row or column to sort by. (optional)
Sort order A number indicating the desired sort order; 1 for ascending order (default), -1 for descending order. (optional)
By col A logical value indicating the desired sort direction; FALSE to sort by row (default), TRUE to sort by column. (optional)

Worked examples

Reproduce these source cells: B1=10, B2=20, B3=30, B4=40, B5=50.

Full array output: FILTER, SORT and matrix functions may need a selected output range and Ctrl+Shift+Enter in LibreOffice Calc. The examples below return one scalar result that was tested directly.

Example 1: Find the highest value in a sorted descending result

=INDEX(SORT(B1:B5;1;-1);1)

Expected result: 50. This value was returned in the LibreOffice Calc 25.2 test.

Example 2: Get the smallest value from a sorted ascending array

=INDEX(SORT(B1:B5;1;1);1)

Expected result: 10. This value was returned in the LibreOffice Calc 25.2 test.

How to interpret the result

In the example B1:B5 contains 10,20,30,40,50. Sorted descending, the first value is 50; sorted ascending, it is 10.

Mistakes and troubleshooting

  • Check inputs and assumptions: To return the entire sorted array, use an appropriately sized formula output rather than a single-cell INDEX result.
  • Check argument order and format: Strings go in quotes, cell references do not. Functions that return arrays may require special entry.
  • Verify your own data: Reproduce the example first. If your formula returns an error, inspect the referenced cells and individual argument values.

Tested version and primary reference

This function is available since LibreOffice 24.8, according to the LibreOffice function documentation.

2 example(s) on this page passed real calculations in LibreOffice Calc 25.2.3.2. This is not a claim about every possible input or other spreadsheet applications.