Home Guides Text Guides

Text Guides

How to Sort a List of Text or Numbers

Learn how to sort text and numbers correctly, clean whitespace, understand case-sensitive ordering and distinguish sorting from duplicate removal.

In this guide Step-by-step explanations, practical examples and useful context to help you complete the task confidently.

Sorting arranges names, keywords, identifiers or numeric values into a chosen order. The most important decision is whether the values should be compared as text or as numbers. Input cleanliness and comparison rules also affect the result.

Text sorting versus numeric sorting

Text sorting compares character sequences, while numeric sorting compares numerical values. For example, sorting the values 2, 10 and 3 as text may place 10 before 2; numeric sorting gives 2, 3, 10. Select the mode that matches the meaning of the data.

Sort with Tervilo

  1. Open the Tervilo Text Sorter.
  2. Paste the list, preferably with one item per line.
  3. Choose ascending or descending order.
  4. Select text or numeric behaviour as appropriate.
  5. Run the sort, then inspect the first, last and a few middle entries.

Prepare the input

Remove accidental leading or trailing spaces and decide how to handle blank lines before sorting. Entries that look identical can be treated differently if one contains hidden whitespace. Do not normalize text automatically if those differences are meaningful for the task.

Ascending and descending order

Ascending order usually means A to Z or smallest to largest; descending reverses that order. For dates, currency, version numbers or values with units, a plain text sorter may not interpret the values as intended. Use a spreadsheet or database with an appropriate field type for structured data.

Case and locale can affect order

Some sorters distinguish uppercase from lowercase, and sorting rules for accented letters or different languages may vary. If the list contains names or labels with mixed capitalization, review the output instead of assuming the order will match a person's natural-language expectations.

Sorting does not remove duplicates

Sorting changes the order of entries; it does not make repeated values unique. If you need a unique list, remove duplicate lines as a separate step and then sort the cleaned result. If duplicates carry meaning, retain them.

When a plain text sorter is not enough

Lists containing multiple columns, dates, currency values or structured records need a method that understands each field. Sorting a CSV file as raw lines can produce the wrong result when the desired order depends on a particular column.

Common mistakes

  • Using text sorting for numeric values.
  • Sorting before checking whitespace and blank lines.
  • Expecting sorting to remove duplicates.
  • Assuming mixed-case or multilingual text always follows one universal order.
  • Sorting structured rows as plain text when a field-specific sort is required.

Verification checklist

  • Each item is on the intended line.
  • Text or numeric sorting was selected deliberately.
  • Ascending or descending order matches the requirement.
  • Whitespace and blank-line handling are understood.
  • Duplicates were retained or removed intentionally.
  • The output was reviewed before being used elsewhere.

Quick answer

Use text sorting for character-based lists and numeric sorting for numbers. Clean the input carefully, understand how case and whitespace affect order, and remember that sorting and deduplication are separate operations.

You've reached the end

Use the related tools, FAQs and next guides below to continue from the topic you just learned.

Use the solution

Try the Tervilo Tools

Finish the task with a practical Tervilo tool related to this guide.

Questions & answers

Frequently Asked Questions

Why does text sorting put 10 before 2?

A text sort compares characters, so '10' can come before '2'. Use numeric sorting when the values represent numbers.

Does sorting remove duplicate lines?

No. Sorting only changes order. Use a deduplication tool when repeated values should be removed.

Should I clean whitespace before sorting?

Yes, especially when leading/trailing spaces could make visually identical items compare differently.

Can a text sorter handle complex spreadsheets?

A plain text sorter is best for line-based data. Structured multi-column data is usually better handled in a spreadsheet or database.

Learn more

Related Articles

Understand the wider topic with an informative Tervilo article.