Collabora Office SORTBY: Sort records with separate one-dimensional keys
Sort arrays by one or more matching key vectors in the new Linux desktop build, with numeric priorities, direction and shape checks.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: =SORTBY(A2:C5;B2:B5;1;C2:C5;-1) orders four records by column B ascending, then column C descending within each tied B value. The returned array keeps the same shape as A2:C5. The original records are not rearranged in place.
Syntax, defaults and key orientation
=SORTBY(Range; SortByRange1 [; SortOrder1 [; SortByRange2; SortOrder2 ...]])
The 26.04 help defines 1 as ascending and −1 as descending, with ascending as the default. Keep each key beside its direction in a multi-key expression. Explicit directions make the priority easier to audit.
A vertical, one-column key vector sorts rows and must contain one key for each source row. A horizontal, one-row key vector sorts columns and must contain one key for each source column. Multiple key vectors must have the same orientation and matching length. A two-dimensional key block is not a substitute for a sequence of separate vectors.
Keys can be outside the returned range, provided positions correspond. The first key is the highest priority; the second resolves ties in the first, and so on. SORTBY has no header argument. Exclude headings from both the returned data and the keys unless you intentionally want them sorted as data.
Worked example: group priority, then descending quantity
Enter this complete table in A1:C5:
| Row | A: Item | B: Group code | C: Units |
|---|---|---|---|
| 1 | Item | Group code | Units |
| 2 | Pen | 2 | 12 |
| 3 | Pad | 1 | 8 |
| 4 | Clip | 2 | 15 |
| 5 | Book | 1 | 10 |
Use =SORTBY(A2:C5;B2:B5;1;C2:C5;-1). The independently ordered result is:
| Item | Group code | Units |
|---|---|---|
| Book | 1 | 10 |
| Pad | 1 | 8 |
| Clip | 2 | 15 |
| Pen | 2 | 12 |
First divide the rows into group 1 and group 2. Within group 1, 10 precedes 8; within group 2, 15 precedes 12. Entire records move together, so the quantities remain attached to the correct item names. The displayed column labels above explain the result; they are not extra rows returned by the formula.
For a single numeric key, =SORTBY(A2:C5;C2:C5) independently gives Pad, Book, Pen, Clip in ascending Units order. Adding ;-1 reverses the quantity order to Clip, Pen, Book, Pad.
Advanced use: reorder columns by an external priority row
In a fresh area enter A1:C2 as rows A | B | C and 10 | 20 | 30. Put priorities 3 | 1 | 2 in A4:C4. Then:
=SORTBY(A1:C2;A4:C4;1)
The independently derived result is rows B | C | A and 20 | 30 | 10. Because the key vector is horizontal, columns move as units while both rows are retained. This is useful for presenting metrics in an explicitly maintained priority order without embedding priority values inside the output.
Ties, text and errors
The pinned ordering and comparison helpers resolve equality across all keys using original positions. Thus =SORTBY(A2:C5;B2:B5;1) has source-derived order Pad, Book, Pen, Clip. For reports that need a business-defined tie-breaker, supply that key explicitly rather than assuming the existing source order conveys one.
Text comparison uses the engine collator with its default case-insensitive sort setting. Locale-sensitive alphabetic ordering, accented characters and mixed text/number keys should be checked separately; the reproducible keys here are ordinary numbers. Error-bearing keys do not have a documented ignore-errors option, so clean or explicitly handle them before relying on a ranking.
=SORTBY(A2:C5;C2:C4;1) fails the source dimension check because three keys cannot describe four records. =SORTBY(A2:C5;C2:C5;0) follows internal IllegalParameter; use the documented 1 or −1 directions. A source reference spanning sheets is also rejected. The exact UI error display has not been observed here.
The ScSortBy evaluator establishes key orientation and shape, while the helpers establish actual ordering and result construction. The resulting array is not evidence that formats, comments or validation rules move with values, nor proof of a particular spill UI.
Product scope, compatibility and evidence
This guide covers the new Collabora Office desktop for Linux, using the Flathub source tag coda-26.04.4.3-1 and commit 81339d176148d0d5c81ff05d82540f58f8aaa117. The official desktop release notes and Linux package manifest identify that product/build. The package manifest is a dated observation from October 18, 2026, rather than an installed-binary check.
The 26.04 function help and exact evaluator source were inspected on October 18, 2026. Expected examples were independently calculated; no Collabora application was run. Expected values and arrays describe source-derived results, not verified keyboard entry or automatic spill behavior. Classic, Online/CODE, other operating systems and file-format round trips require their own checks.
The help identifies this function as outside OpenDocument 1.3 and uses the extension name COM.MICROSOFT.SORTBY. That does not establish lossless export to every spreadsheet format. The first Collabora release introducing it is not established by these sources. It is documented here as available, with no cited retirement or deprecation notice; an undocumented introduction date is not a deprecation claim.
Related functions
- TAKE: select a leading or trailing portion after establishing order
- CHOOSECOLS: project selected columns without sorting