Why Google Sheets "Sort Range" Puts Parentheses Above Numbers
When using the Sort Range feature in the Google Sheets web application, you may notice a confusing behavior: rows containing numbers wrapped in parentheses often jump to the top of the list, even appearing above the number zero. To a human eye, these might represent negative values or special categories, but to the Google Sheets sorting algorithm, they are handled based on character encoding and data types.
Here is the technical breakdown of why this happens and how to fix it.
1. The ASCII/Unicode Sorting Logic
Google Sheets sorts data based on a specific hierarchy. When it encounters "Plain Text" instead of "Numbers," it defaults to the Unicode character order.
- In the Unicode/ASCII table, the open parenthesis "(" has a decimal value of 40.
- The number "0" has a decimal value of 48.
- Since 40 is less than 48, the sorting engine interprets any string starting with a parenthesis as "smaller" or "coming before" any string starting with a digit.
2. The "Text vs. Number" Conflict
The most common reason parentheses appear above numbers is that Google Sheets is treating those cells as Plain Text rather than numerical data. This often happens when:
- The data was imported from a CSV or a web scrape.
- The numbers were manually typed with parentheses instead of using a minus sign (-).
- The cell has a leading apostrophe (e.g.,
'(100)).
If the cell is recognized as a number, Google Sheets will ignore the formatting and sort by value. If it is recognized as text, it sorts by the leading character—the parenthesis.
3. Financial Formatting vs. Manual Parentheses
In accounting, negative numbers are traditionally shown in parentheses (e.g., ($500.00)). There is a critical difference in how the web application handles this:
- Manual Entry: If you type
(100), Sheets may see this as a text string. It will sort to the top because of the ASCII rule. - Accounting Format: If you type
-100and then apply Format > Number > Accounting, the cell still contains a raw number. Google Sheets will sort this correctly as a negative value, placing it below zero in an ascending sort.
4. How to Fix the Sorting Order
If your "Sort Range" results are cluttered with parentheses at the top, follow these steps to clean the data:
- Highlight the Column: Select the data range in question.
- Convert to Numbers: Go to Format > Number > Automatic or select a specific number format.
- Use Find and Replace: If the numbers remain text, press
Ctrl + H. Find(and replace with nothing, then find)and replace with nothing. Ensure negative values are preceded by a minus sign. - Check for Leading Spaces: Sometimes a space before a number (which has a Unicode value of 32) will also cause it to jump to the very top.
5. Using the SORT Function as an Alternative
If the "Sort Range" tool continues to fail, you can use a formula to force a numerical sort. Using the VALUE function inside a sort can strip away text formatting:
=SORT(A2:B10, ARRAYFORMULA(VALUE(SUBSTITUTE(SUBSTITUTE(A2:A10, "(", "-"), ")", ""))), TRUE)
This advanced workaround tells the web application to treat the parentheses as negative signs for the duration of the sort operation.
Conclusion
Google Sheets puts parentheses above numbers during a sort because it is interpreting those cells as strings rather than values. By understanding the Unicode priority where ( (40) precedes 0 (48), you can diagnose data entry errors. For the cleanest results, always use numerical formatting rules to display negative values in parentheses rather than typing the symbols manually.
