Sort Leading-Zero Codes and Text Values in WPS Spreadsheet
Question details
Sort a column containing leading-zero codes, alphanumeric values, and text entries without losing leading zeros or getting inconsistent results.

- Product
- WPS Spreadsheet
- Device & OS
- not provided
- Scenario
- The user needs to sort values such as 000511, 018952, 017866A10, and TM0004 in one consistent order.
- Observed behavior
- Mixed numeric and text cell types can sort differently, while codes with leading zeros must remain unchanged.
Decide whether every entry is an identifier or code rather than a number for calculation. If leading zeros are meaningful, keep the entire column as text before sorting.
Convert the code column to text and sort from A to Z
Use this method when all entries are codes or identifiers and leading zeros must be preserved.
A consistent text format lets WPS Spreadsheet compare leading-zero values, alphanumeric codes, and words using one sorting rule. Text sorting places entries in alphabetical and character order.
Click the column letter that contains the codes, such as the column with 000511, 017866A10, and TM0004.
Go to Home > Number Format and select Text. This ensures new or edited values in the selected cells are treated as text.
With the column selected, go to Data > Text to Columns, choose Delimited, click Next, clear any delimiter selections, click Next, select Text under Column data format, and click Finish.
Click any cell in the column, then go to Data > Sort A to Z. If WPS Spreadsheet asks whether to expand the selection, choose Expand the selection to keep related row data together.

Use a helper column when numeric values must remain numeric
Use this method when the original values are needed for calculations but you also need a code-style sort order.
Sort Mixed Codes Reliably with WPS Spreadsheet
WPS Spreadsheet lets you format identifier columns as text, convert mixed entries to a consistent type, and sort codes from A to Z while retaining meaningful leading zeros.
- 1. Open the worksheet in WPS Spreadsheet: Open your XLSX or XLS file in WPS Office and select the worksheet containing the code column.
- 2. Format identifier cells as text: Select the relevant column and choose Home > Number Format > Text.
- 3. Standardize current entries: Use Data > Text to Columns and select Text as the column data format when existing cells contain mixed data types.
- 4. Apply an ascending sort: Select a cell in the data range and choose Data > Sort A to Z, expanding the selection when prompted.

Frequently Asked Questions
Why do codes with leading zeros sort differently from other values?
Cells such as 000511 are often stored as text, while other entries may be stored as numbers. WPS Spreadsheet applies different comparison rules to text and numeric values, so converting the column to one type produces a more consistent result.
Will formatting a cell as Text restore zeros that were already removed?
No. Changing Home > Number Format > Text prevents future numeric interpretation, but it cannot restore zeros that were previously removed. Re-enter the complete code, use the original source data, or use a TEXT formula when the required code length is known.
How do I sort related rows without separating their data?
Click a cell in the table before selecting Data > Sort A to Z. When the sort prompt appears, choose Expand the selection so WPS Spreadsheet moves every cell in each row together.
Should codes such as 017866A10 and TM0004 be stored as numbers?
No. Because these are identifiers containing letters and leading zeros, store them as text. Text format preserves every character and supports consistent alphabetical sorting.
Can WPS Spreadsheet sort Excel XLSX files with leading-zero codes?
Yes. WPS Spreadsheet supports XLSX and XLS files. Format the identifier column as Text, standardize mixed values if necessary, and use Data > Sort A to Z.




