# How to sort words in a cell alphabetically in Excel

Split the list into rows, sort it and join it back: =TEXTJOIN(", ",TRUE,SORT(TEXTSPLIT(A2,,", "))).

**Excel:** `=TEXTJOIN(", ",TRUE,SORT(TEXTSPLIT(A2,,", ")))` (Excel 2024 and Microsoft 365)

**Google Sheets:** `=JOIN(", ",SORT(TRANSPOSE(SPLIT(A2,", ",FALSE))))`

## Example

Sample data (row 1 is the header):

| A | B |
| --- | --- |
| Tags | Sorted |
| red, blue, green |  |
| oak, walnut, birch, ash |  |
| zinc |  |
| steel, brass |  |
| pine, maple, cedar |  |

Formula in B2, filled to B6: `=TEXTJOIN(", ",TRUE,SORT(TEXTSPLIT(A2,,", ")))`

Result: blue, green, red; ash, birch, oak, walnut; zinc; brass, steel; cedar, maple, pine

## How it works

SORT works on lists, not on text in one cell, so TEXTSPLIT first turns the cell into a column of words (", " is the row delimiter, the third argument). SORT puts them in order and TEXTJOIN joins them back with the same separator.

Google Sheets' SPLIT returns a row, so TRANSPOSE turns it into a column before SORT.

## Other ways

- `=TEXTJOIN(", ",TRUE,SORT(TEXTSPLIT(A2,,", "),,-1))`: Z to A: -1 is the descending sort order. ("red, green, blue" and so on.)

## Common mistakes

- Splitting with ", " in the second argument gives a row, and SORT sorts rows by default, so nothing changes. Split into rows, or use `SORT(…,,,TRUE)` to sort a row.
- Lists typed with and without spaces after commas split badly. Split on "," and TRIM: `SORT(TRIM(TEXTSPLIT(A2,,",")))`.

## Questions

**How do I sort and remove duplicates?**

Add UNIQUE: `=TEXTJOIN(", ",TRUE,SORT(UNIQUE(TEXTSPLIT(A2,,", "))))`.

**Can I sort the letters of a single word?**

Split into characters instead: `=CONCAT(SORT(MID(A2,SEQUENCE(LEN(A2)),1)))`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/sort-words-in-a-cell-alphabetically
