Formatting Issues

Sort Leading-Zero Codes and Text Values in WPS Spreadsheet

Jason MillerJason Miller Nov 12, 2026 868 views

Question details

Sort a column containing leading-zero codes, alphanumeric values, and text entries without losing leading zeros or getting inconsistent results.

Sort Leading-Zero Codes and Text Values in WPS Spreadsheet
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.
Before you start

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.

Solution 1Recommended

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.

1
Select the code column

Click the column letter that contains the codes, such as the column with 000511, 017866A10, and TM0004.

2
Set the cells to Text format

Go to Home > Number Format and select Text. This ensures new or edited values in the selected cells are treated as text.

3
Convert existing mixed values if needed

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.

4
Sort the column

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.

Convert the code column to text and sort from A to Z
Leading zeros stay visible: When the values are stored as text, entries such as 000511 and 018952 retain their leading zeros during sorting.
WPS Spreadsheet

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. 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. 2. Format identifier cells as text: Select the relevant column and choose Home > Number Format > Text.
  3. 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. 4. Apply an ascending sort: Select a cell in the data range and choose Data > Sort A to Z, expanding the selection when prompted.
Format code columns as text to preserve leading zeros.Sort alphanumeric identifiers and text values in a consistent A-to-Z order.Open, edit, and save Microsoft Excel XLSX and XLS files with format compatibility.Use familiar spreadsheet tools such as Text to Columns, formulas, and custom sorting.
microsoft office alternative - wps office

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.