Sort list by symbols

Sort lines by the first symbol character each line contains (matched via `/[^\w\s]/`). Lines with no symbol sort first; remaining lines are grouped by their first-symbol character. Within each group, lines are sorted alphabetically. Useful for grouping regex patterns, Markdown bullet styles, or mixed-prefix SKU lists.

Input
Ready
Output
Live

First-symbol-character grouping

For each line, the op runs `/[^\w\s]/` to find the first character that is neither a word character (`\w`) nor whitespace. That single character becomes the sort key. Lines with no symbol get the empty-string key and sort before any symbol-bearing line.

Two lines with the same first-symbol character fall back to alphabetical comparison (`localeCompare` with natural-order numerics). So `#cherry` sorts before `apple#` under `#` grouping, because `#` appears at position 0 vs. position 5 - but the sort key is only the character `#` for both, so the alphabetical tiebreak decides.

Order flips asc/desc. Case sensitive only affects the alphabetical tiebreak (not the symbol comparison). For sort-by-LAST-character see Sort by last character; for length-based sort see Sort by length.

How to use sort list by symbols

  1. 1Paste your list into the input panel
  2. 2Each line's first symbol character becomes its sort key
  3. 3Lines without a symbol sort first
  4. 4Alphabetical tiebreak within each symbol group
  5. 5Flip Order for descending

Keyboard shortcuts

Drive ListShift without touching the mouse.

Shortcut Action
Ctrl ZUndo last input change
Ctrl Shift ZRedo
Ctrl Shift EnterToggle fullscreen focus on the editor
EscExit fullscreen
Ctrl KOpen the command palette to jump to any tool
Ctrl SSave current pipeline draft Plus
Ctrl PRun a saved pipeline Plus

What this tool actually does

Primary sort by first symbol character, secondary alphabetical.

First-symbol extraction via regex

Each line matched against `/[^\w\s]/`. First match is the sort key. No match → empty-string key (sorts before all symbols).

Alphabetical tiebreak

Lines with the same first-symbol char are ordered alphabetically via `localeCompare` with `numeric: true`. Stable secondary sort.

Order flips both sorts

Descending order reverses both the symbol-group ordering AND the within-group alphabetical tiebreak. Consistent direction throughout.

Case sensitive affects tiebreak only

Symbol comparison is always case-insensitive (symbols have no case). The toggle only influences the alphabetical tiebreak for lines sharing a symbol.

Lines with no symbol sort first

Empty-string sort key is lexicographically smallest. Flip Order to put no-symbol lines LAST instead.

Worked example

Default ascending. No-symbol line first. Within `#` group: `#cherry` < `apple#` alphabetically. Within `@` group: `@banana` < `banana@`.

Input
apple
@banana
#cherry
apple#
banana@
Output
apple
#cherry
apple#
@banana
banana@

Settings reference

How each option shapes the output using the sample above.

Setting What it does Effect on the sample
Order: A→Z (default) No-symbol first, then `#`-group, then `@`-group `apple` / `#cherry` / `apple#` / `@banana` / `banana@`
Order: Z→A Reverses both symbol and alphabetical ordering `banana@` / `@banana` / `apple#` / `#cherry` / `apple`
Case sensitive: on Only affects alphabetical tiebreak within same-symbol group No change on sample (no cased letters in relevant positions)
Line without symbol (automatic) Empty-string key → sorts first (or last with Z→A) `apple` leads the output

FAQ

Which character does it sort by?
The first character in each line that is neither a letter/digit/underscore (`\w`) nor whitespace. So `@`, `#`, `!`, `$`, `.`, `-`, `[`, etc. all qualify.
What happens to lines without any symbol?
They get the empty-string sort key and appear first in ascending order (last in descending). No-symbol lines among themselves are ordered alphabetically via the tiebreak.
Why does `#cherry` sort before `apple#` when both have `#` as their symbol?
The sort key is just `#` for both lines. They tie on symbol, so the alphabetical tiebreak decides - `#cherry` < `apple#` lexicographically (because `#` < `a`).
How do I sort by last-character or last-symbol?
Sort by last character documents a Reverse → Sort → Reverse workflow for trailing-character ordering.
Is the sort stable?
Yes - ES2019+ stable sort. Lines with identical primary + secondary keys keep their original relative order.