Sort characters in text
cabana becomes aaabcn: all 6 characters lined up in Unicode order, repeats included. Spaces, punctuation and emoji are kept and sorted too, so two exact anagrams always give the same result. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Text
- cabana
- Text
- aaabcn
- Characters
- a, a, a, b, c, n
- Quantity
- 6
- Original
- cabana
Sort characters in text turns a string into an ordered view of every letter, number, space, punctuation mark, symbol, and emoji it contains. Repeated characters remain repeated, so the result is especially useful when you want to compare possible anagrams, inspect the raw composition of a phrase, or prepare clues for a cipher puzzle. The sorter treats user-perceived Unicode characters as complete units whenever the runtime supports grapheme segmentation, then orders them by their Unicode code-point sequences. It is deterministic, does not change case, and does not silently remove whitespace.
What character sorting reveals
Sorting characters removes the distraction of their original positions while preserving the exact contents of the text. If two words are true anagrams under an exact comparison, their sorted results will match because both contain the same characters with the same multiplicities. The same view can expose an unexpected extra space, a repeated punctuation mark, a missing digit, or a difference in letter case that is difficult to notice in ordinary prose.
This capability includes every character rather than selecting letters only. Spaces therefore move toward the beginning under Unicode order, digits generally appear before uppercase Latin letters, and uppercase Latin letters generally appear before lowercase ones. Punctuation and characters from other scripts take positions determined by their Unicode code points.
That behavior is intentional and makes the result reproducible instead of dependent on a dictionary, a changing locale, or human language rules. Repeated characters are never deduplicated. The response supplies the joined sorted text as well as an array of the sorted characters, allowing a person to scan the result or an application to count and compare entries without splitting the string again.
The original text is also returned so logs and interfaces can show a clear before-and-after comparison.
How Unicode characters are handled
Modern text is not safely represented by treating every UTF-16 code unit as a complete character. Many emoji occupy surrogate pairs, accented letters may combine a base letter with one or more marks, and family or profession emoji can contain several code points connected into one displayed symbol. Splitting those sequences carelessly produces broken output and makes character counts misleading.
This sorter uses grapheme segmentation when Intl.Segmenter is available, keeping user-perceived symbols together before it orders them. In a runtime without that standard facility, it falls back to Unicode code-point iteration, which still avoids splitting surrogate pairs. Once segmented, characters are compared by their code-point sequences from left to right.
This explicit comparison avoids locale-dependent collation and produces the same ascending rule for Latin text, other scripts, punctuation, and emoji. The input is not normalized before sorting. That detail matters: an accented letter encoded as one precomposed code point is not automatically made equivalent to the same visible letter encoded as a base character plus combining mark.
Such distinctions are valuable when inspecting exact character composition or debugging encoding differences. If your goal is a language-aware alphabetical list, use a collation-oriented sorter instead; this capability deliberately describes the text at the character level.
Using the result for anagrams, puzzles, and automation
For an exact anagram check, send each candidate phrase separately and compare the returned text fields. Decide before comparing whether spaces, punctuation, capitalization, or accents should matter. Keeping that policy outside the capability prevents hidden transformations and lets strict comparisons remain genuinely exact.
Cipher and word-game tools can use the characters array to display an ordered inventory, identify repeated symbols, or construct hints without writing their own Unicode splitter. Data-quality workflows can sort short identifiers or tokens to reveal composition differences that visual inspection misses. The only required field is text, and it must be a non-empty string; whitespace-only text is accepted because whitespace itself can be the subject of inspection.
For very large documents, split the material into meaningful pieces so each response remains easy to inspect and compare.
What you can do with it
Check exact anagrams
Sort two candidate words or prepared phrases and compare their results to confirm that every character occurs the same number of times.
Build cipher and word puzzles
Turn a clue into an ordered character inventory that makes duplicates and available symbols easy to inspect without revealing the original order.
FAQ
What order does the sorter use?
It uses ascending Unicode code-point sequence order, not dictionary or locale-specific alphabetical order.
Are spaces and punctuation removed?
No. Every input character is preserved, including whitespace, punctuation, symbols, and duplicates.
Can I use it to check anagrams?
Yes. Apply the same preprocessing rules to both phrases, sort each one, and compare the returned text values.
Does it keep emoji intact?
It uses Unicode grapheme segmentation when available, so joined and multi-code-point emoji remain complete; the fallback iterates by code point.
Why do accented letters end up after z?
Because the order follows each character's Unicode number, not a dictionary. Plain Latin letters come first, so é, ñ or ü land after z. Capitals also come before lowercase letters, and the order is the same on every device.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/str/sort-characters \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"cabana"}'const res = await fetch("https://api.kit.forhosting.com/str/sort-characters", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"text": "cabana"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/str/sort-characters",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"text": "cabana"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/str/sort-characters", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"text":"cabana"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"text":"cabana"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/str/sort-characters", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"text": "cabana"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "str.sort_characters",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
You can run it free in the browser or call the same operation through the API for $0.002 per item.
Using the result for anagrams, puzzles, and automation
This endpoint preserves all of them, so a relaxed puzzle rule should preprocess both inputs consistently—for example, remove spaces and convert case—before calling the sorter. Missing text, an empty string, or a non-string value returns invalid_input. Browser use is free, while automated API execution costs $0.002 for each successful item.
Integration use cases
Inspect token composition
Expose subtle differences in spaces, punctuation, capitalization, accents, or repeated symbols within short identifiers and test fixtures.
Technical questions
How much does the API call cost?
A successful API item costs $0.002. The browser version runs free on your device.