Function Problems

How to Sort and Normalize Comma-Separated Values in Excel

Anum MushtaqAnum Mushtaq Nov 11, 2026 869 views

Question details

The user needs to rearrange comma-separated values inside individual cells into a consistent, sorted alphabetical order.

How to Sort and Normalize Comma-Separated Values in Excel
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.
Before you start

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).

Solution 1Recommended

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.

1
Select the destination cell

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).

2
Enter the sorting formula

Type the formula =TEXTJOIN(", ",TRUE,SORT(TRANSPOSE(TEXTSPLIT(B2,", ")))) into the formula bar.

3
Apply and drag to fill

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.

Sort Values in a Single Cell Using TEXTJOIN, SORT, and TEXTSPLIT
Adjusting the Separator: If your source data uses commas without any following spaces, make sure to adjust the TEXTSPLIT delimiter from ", " to "," in your formula to avoid retaining unnecessary spaces.
Advanced Data Processing

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. 1. Open your workbook: Launch WPS Spreadsheet and open the file containing your disorganized comma-separated lists.
  2. 2. Input the array formula: Select a blank cell and enter your TEXTJOIN, SORT, and TEXTSPLIT combination exactly as you would in Excel.
  3. 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. 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.
Fully compatible with Microsoft Excel formulas and the standard .xlsx file format.Supports dynamic arrays and advanced text processing functions to streamline data cleaning.Lightweight, fast, and completely free to use with a familiar tabbed user interface.Available across Windows, Mac, Linux, iOS, and Android for seamless file management.
microsoft office alternative - wps office

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.