SORTBY in WPS Spreadsheet: Sort a List Using a Separate Aligned Key
Use one explicit SORTBY key and direction in WPS, return only the needed labels, and keep key ranges aligned.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: =SORTBY(A2:A5,C2:C5,-1) returns A2:A5 in descending order of the corresponding numbers in C2:C5. The key can remain outside the returned result.
Availability and evidence scope
The official WPS SORTBY lesson documents the behavior used here. It identifies WPS Office for Windows Personal. Reviewed October 19, 2026, this Chinese-language evidence does not establish an exact introduction build, every current edition, or English-global, Mac, Linux, web or mobile behavior. No new WPS execution or native screenshot was possible; the examples are independent controls or explicitly conditional fixtures.
Historical entry method versus newer releases
The 2021 lesson demonstrates selecting the complete result range, entering the formula and pressing Ctrl+Shift+Enter. Braces shown around an array formula are added by that workflow; do not type them as part of the formula. That historical method is the reproducible workflow described here.
The official Windows release log separately announces dynamic arrays in October 2023. Consequently, the older lesson’s no-dynamic-array statements are historical, not a claim that current WPS cannot expand array results. For a newer installation, confirm its array-entry behavior and available output space in that build. This guide does not import Excel spill rules, error codes, spill-reference operators or cross-workbook behavior into WPS. Monthly release notes do not establish an exact introduction build for SORTBY.
Syntax and arguments
=SORTBY(array,by_array1,sort_order1,[by_array2,sort_order2],...)
This normalizes the WPS lesson’s array followed by sorting-array/order pairs. The examples supply one complete pair; optional additional pairs are shown for orientation, not tested here.
array: records or labels to return.by_array1: values used to decide their order. Each value must correspond to the same record position inarray.sort_order1: 1 means ascending and -1 descending in the lesson.- Further pairs provide more sorting criteria. No current maximum count is asserted from the historical lesson’s stated limit.
Equal row counts are necessary for this fixture but not sufficient: a shifted key range can still attach the wrong priority to each item. Use identical starting and ending rows.
Example 1: a priority queue without exposing the score
Enter the following source:
| Row | A: Task | B: Owner | C: Priority score |
|---|---|---|---|
| 2 | Draft | Mira | 30 |
| 3 | Review | Leon | 10 |
| 4 | Export | Chen | 40 |
| 5 | Archive | Noor | 20 |
For the 2021 method, select E2:E5 and enter =SORTBY(A2:A5,C2:C5,-1) with Ctrl+Shift+Enter. Independently, 40 > 30 > 20 > 10, so the returned names should be Export, Draft, Archive, Review.
Only the task labels are returned. The priority column influences the sequence but is not included in the output. This is useful for a concise work queue where readers need the next task rather than the internal score.
Example 2: keep ownership attached to the task
Select a separate 4-by-2 output range under the historical workflow and enter:
=SORTBY(A2:B5,C2:C5,1)
Expected pairs are Review/Leon, Archive/Noor, Draft/Mira, Export/Chen. The ascending scores are 10, 20, 30, 40. Expanding the return array from one to two columns carries the owners along without changing the key range.
To reproduce a changed priority, replace C3 with 50. Descending order for =SORTBY(A2:B5,C2:C5,-1) then becomes Review/Leon, Export/Chen, Draft/Mira, Archive/Noor. This is a conditional arithmetic expectation for the revised fixture, not a newly observed WPS run.
Troubleshooting and limits
- Do not sort the key column separately before applying this formula. It must retain each row’s association with the task.
- Avoid including headers in either array. A text label is not one of the numerical priorities.
- A one-column output will not display owners even if the key is correct; choose the complete return block you need.
- Tied values, mixed types and additional key pairs require separate checks. These examples use unique numerical keys.
- The historical source mentions up to 126 pairs. It does not establish that this is the current limit in all editions, so this guide does not use it as a compatibility promise.
Compare SORT when the key is a numbered column inside the return array. Use XMATCH when the goal is one item’s relative position instead of a reordered list.
References and verification
Expected outputs are derived from the explicit fixtures and documented operation. They are not results observed in an installed WPS build. Check the intended edition before relying on these formulas in a shared workbook.