Card Sort
Runs entirely on your device — works with the network off, no ads, no account, no tracking.
- Works offline
- Keyboard playable
- Screen-reader playable
- No ads, no account
- No betting, no money, no prizes
- 1–3 minAll ages
How many adjacent swaps does it take to sort a row of cards?
Exactly as many as it has inversions — pairs of cards that are in the wrong order relative to one another, whether or not they are next to each other. Count every pair where a higher rank sits to the left of a lower one, and that total is the answer, not an estimate. Two facts pin it down. First, a swap of two neighbours re-orders exactly one pair — the two cards it touches — and leaves every other pair alone, because no other pair has both of its members move; so each swap changes the count by exactly one, and a sorted row has a count of zero. Nothing shorter than the count can get there. Second, while the count is above zero some neighbouring pair must be out of order, so a swap that lowers it always exists. A lower bound that is always reachable is the minimum, and it is what this game prints above the row.
Row 8 3 9 2 J Q. 4 swaps still needed, 7 left. Cursor between card 1 and card 2: 8 and 3, out of order, so swapping here needs one swap fewer.
← → move along the seams · Enter swap the two cards either side · ↑ ↓ jump to the nearest out-of-order pair left or right · F jumps to the nearest one either way. Click the row first, or press Tab to focus it.
What this builds
DOMAIN — the fewest side-by-side swaps that sorts a row is exactly its inversion count, because one swap changes that count by exactly one
Sort a row of cards when the only move is to swap two that sit side by side
Six cards lie face up in a row, out of order. There is exactly one move: choose the boundary between two neighbouring cards and exchange them. You cannot lift a card out and drop it further along, you cannot reverse a run, and you cannot reach past the card next door. What makes this more than fiddling is the number printed above the row: the fewest swaps that can possibly sort it, worked out before you start and counted down as you play. Every swap you make moves that number by exactly one — down if the pair you exchanged was out of order, up if it was not — so the whole round is a running proof rather than a guess.
It runs entirely on your device: 0 network requests, works offline. No ads, no account, nothing to buy, and no betting, money or prizes of any kind.
How to play
- Focus the board — click it, or press Tab until it is focused.
- Move the cursor along the boundaries with Left and Right. The cursor sits between two cards, not on one, because the boundary is where the move happens. Each boundary is labelled with what using it would cost: −1 when the pair is out of order, +1 when it is not.
- Swap with Enter or Space, or click the boundary. That spends one move, whichever way the count goes.
- Jump to a swap that helps with Up for the nearest out-of-order pair on the left and Down for the nearest on the right. F takes the nearest one in either direction. A single row has no vertical axis, so those keys are given to the only jump worth making, and jumping costs nothing.
- Watch the two numbers. Swaps needed is the exact minimum from where you stand now; Moves is what you have spent against the budget. When Swaps needed reaches zero the row is in order and you have won.
- Undo costs two. There is no free undo, because a wrong swap and the swap that takes it back are both moves. That is the entire reason the budget is the minimum plus three rather than plus one.
Cards marked ✔ are already on the slot they finish on. Suits are decoration and no rule reads them.
FAQ
How many adjacent swaps does it take to sort a row of cards?
Exactly as many as it has inversions — pairs of cards that are in the wrong order relative to one another, whether or not they are next to each other. Count every pair where a higher rank sits to the left of a lower one, and that total is the answer, not an estimate. Two facts pin it down. First, a swap of two neighbours re-orders exactly one pair — the two cards it touches — and leaves every other pair alone, because no other pair has both of its members move; so each swap changes the count by exactly one, and a sorted row has a count of zero. Nothing shorter than the count can get there. Second, while the count is above zero some neighbouring pair must be out of order, so a swap that lowers it always exists. A lower bound that is always reachable is the minimum, and it is what this game prints above the row.
Why does the game show me the answer before I start?
Because the number is not the answer, it is the ruler. Knowing the row needs seven swaps tells you nothing about which seven, and finding them is the game. What it does do is make every move honest: you can see immediately whether the swap you just made was one of the seven or a detour that now costs you two. That is a much better teacher than a score you only understand at the end, and it is why the count is on screen the whole time rather than revealed afterwards.
Is every row actually sortable inside the budget?
Yes, by construction and then by measurement. Each row starts as six cards in ascending order and is scrambled by six to nine side-by-side swaps. A swap is its own inverse, so replaying those same boundaries in the opposite order puts the row straight back — a solution exists before the board is ever drawn. Then the exact inversion count of the dealt row is computed, and that is the budget, plus three. So the shortest route is always inside what you are given, and a loss is always a detour rather than a bad deal.
Do the suits mean anything?
No. Spades, hearts, diamonds and clubs are decoration, and nothing in the rules reads them — a 7 of clubs behaves identically to a 7 of hearts. They are printed because a rank with a suit reads as a card rather than as a number in a box. If you find yourself hunting for a suit pattern, there isn't one, and the tests assert it: rewriting every suit on the board leaves every count, every legal move and the result identical.
Why does swapping an in-order pair cost me two moves?
Because it adds an inversion that was not there before, and you then have to remove it again. The count goes up by one, and the swap that takes it back is a second move. So the true price of a wrong turn is two, which is exactly what the margin of three is sized for: one mistake, corrected, with one move to spare. It is also why the boundary labels show +1 before you commit rather than after.
Is there any money, betting or in-app purchase in this?
None, and there never will be. The cards are ranks on tiles: no currency, nothing to buy, no wager of any kind, and no gambling mechanic anywhere in the game. There is no score to buy your way up and no ad to watch.
Can I play it with a keyboard or a screen reader?
Both. Left and Right walk the boundaries, Up and Down jump to the nearest out-of-order pair on either side, F takes the nearest one, and Enter swaps. Every card announces its rank, its suit in words, and whether it is already on its finished slot; every boundary announces the two ranks it separates and whether using it needs one swap fewer or one more; the board announces how many swaps are still needed and how many moves are left. Every state carries a glyph — ✔, ▼, ▲ — so nothing at all depends on telling one tint from another.
Does it work offline?
Yes. Once the page has loaded once, the whole game is on your device — the deal generator, the counter, the rules, the copy. Nothing is fetched while you play, and no result leaves the device.
Limits
Six cards, six distinct ranks drawn from A to K, and one move: exchange two neighbours. Rows are built from six to nine random swaps of the finished order, so the minimum is between four and nine — enforced by construction, never by dealing again until something looks right. The counter is exact rather than estimated, which is affordable because six cards make only fifteen pairs to check; a much longer row would want a merge-sort counter instead, and that is the reason the row is six and not sixty. There is no free undo and no hint that plays a move for you.
Related
Rank Sort is the same row of cards with a different single move — reverse the front of the row instead of swapping neighbours — and the contrast is the lesson: the cheap move there is expensive here and the other way around. Sort Race is the same ordering instinct under time rather than under a move budget. Stack Order and Card Ladder are the two games about the cost of burying the thing you need last. Gap Logic uses the same swap-distance arithmetic on a row you have to deduce rather than one you can see.
Bookmark this page (Ctrl+D, or ⌘D on Mac) or install the app — it works offline the next time you need it.
Have a question or feedback about this game?
Private: this note isn't tracked, and nothing you did in this game is sent — only what you type here.