How to Sort and Normalize Comma-Separated Values in Excel
Question details
The user needs to rearrange comma-separated values inside individual cells into a consistent, sorted alphabetical order.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Cleaning and standardizing dataset formats where identical items are listed in varying sequences across different cells, and cells contain a varying number of text items.
- Observed behavior
- The user wants a formulaic approach to split the items within a cell, sort them consistently, and join them back together into a single comma-separated string.
Ensure you are using a spreadsheet version that supports modern dynamic array functions such as TEXTSPLIT and SORT. Verify that your text data uses a consistent separator (e.g., a comma followed by a space).
Sort Values in a Single Cell Using TEXTJOIN, SORT, and TEXTSPLIT
This method uses dynamic array functions to split the text within a cell, arrange the items alphabetically, and merge them back together.
By combining TEXTSPLIT to break the text apart, TRANSPOSE and SORT to arrange it, and TEXTJOIN to bring it back together, you can normalize cell data dynamically without using complex macros.
Click on an empty cell next to the data you want to normalize (for example, cell C2 if your comma-separated string is in B2).
Type the formula =TEXTJOIN(", ",TRUE,SORT(TRANSPOSE(TEXTSPLIT(B2,", ")))) into the formula bar.
Press Enter to execute the formula. You will see the values sorted alphabetically. Drag the fill handle down to apply this formatting to the rest of your column.

Bulk Normalize Values Across Multiple Rows Using MAP
Use the MAP and LAMBDA functions to apply the sorting logic to an entire column automatically, bypassing the need to drag the formula manually.
Normalize Values Using a Dynamic Range
This solution refines the MAP formula by checking for the actual count of populated rows, ensuring the formula seamlessly handles dynamically added or removed data.
Clean and Manage Complex Text Data Effortlessly in WPS Spreadsheet
WPS Spreadsheet features a powerful formula engine that supports modern array functions. You can easily use tools like TEXTSPLIT, SORT, and MAP to normalize your datasets efficiently without needing external scripts.
- 1. Open your workbook: Launch WPS Spreadsheet and open the file containing your disorganized comma-separated lists.
- 2. Input the array formula: Select a blank cell and enter your TEXTJOIN, SORT, and TEXTSPLIT combination exactly as you would in Excel.
- 3. Press Enter to execute: Hit Enter to process the formula. The string will be dynamically separated, sorted, and rebuilt into the desired order.
- 4. Drag to fill: Use the fill handle at the bottom right of the cell to drag the formula down to process the rest of your dataset.

Frequently Asked Questions
Why does my formula return a #NAME? error?
A #NAME? error usually means your version of the spreadsheet software does not support new dynamic array functions like TEXTSPLIT, SORT, or MAP. Please update to the latest version of Microsoft 365 or use the latest version of WPS Office.
How can I sort values separated by semicolons instead of commas?
You can change the delimiter directly in the formula. Replace ", " with "; " in both the TEXTSPLIT extraction argument and the TEXTJOIN merging argument.
Will this formula remove extra empty values or double commas?
Yes. By setting the second argument in the TEXTJOIN function to TRUE (or 1), the formula is instructed to ignore empty strings, which effectively cleans up double commas or empty items during the rejoining process.
Can I sort the values in reverse alphabetical (descending) order?
Yes. You can modify the SORT function by adding the sort_order argument. Change SORT(array) to SORT(array, 1, -1) to sort the extracted values in descending order before joining them.




