# How to sort a rekordbox playlist by key and BPM

**rekordbox cannot sort by key and BPM at the same time.** rekordbox and the players sort one column at a time, and rekordbox's Renumber Track Order can store only that one-column order in the playlist, so a key then BPM order cannot be stored in one step. **Bake'n Deck's Sort** rewrites the track order inside every playlist of your exported `collection.xml`: **Alphanumeric key ascending, BPM ascending inside each key**. Because the order lives in the playlist and not in a view, the CDJ plays it in exactly that order in its default browse screen.

## Single-column sort vs compound sort

rekordbox and the CDJ-3000 / XDJ-1000MK2 can sort a list by key *or* BPM, one column at a time. Given the same playlist, the three modes produce different orders:

| Sort mode | Key order | BPM within key group |
| --- | --- | --- |
| Sort by Key (single column) | ✓ aligned | ✗ playlist registration order |
| Sort by BPM (single column) | ✗ scattered across the wheel | ✓ aligned, but key grouping is gone |
| Bake'n Deck Sort (key → BPM) | ✓ aligned | ✓ ascending |

## Three sorts, six tracks

Six tracks in a playlist. This is registration order, which is also the order stored in the playlist:

| # | Track | Key | BPM |
| --- | --- | --- | --- |
| 1 | A | 1A | 130 |
| 2 | B | 2A | 124 |
| 3 | C | 1A | 124 |
| 4 | D | 2B | 130 |
| 5 | E | 2A | 128 |
| 6 | F | 2B | 124 |

The same six tracks, under each of the three sorts:

| # | Sort by Key | Sort by BPM | Bake'n Deck (key → BPM) |
| --- | --- | --- | --- |
| 1 | A · 1A · 130 | C · 1A · 124 | C · 1A · 124 |
| 2 | C · 1A · 124 | B · 2A · 124 | A · 1A · 130 |
| 3 | B · 2A · 124 | F · 2B · 124 | B · 2A · 124 |
| 4 | E · 2A · 128 | E · 2A · 128 | E · 2A · 128 |
| 5 | D · 2B · 130 | A · 1A · 130 | F · 2B · 124 |
| 6 | F · 2B · 124 | D · 2B · 130 | D · 2B · 130 |

Sort by key and the BPM inside `1A` and `2B` runs 130 → 124, the opposite direction of a warm-up. Sort by BPM and the key walks `1A → 2A → 2B → 2A → 1A → 2B`. Only the third column keeps the keys in order and the BPM rising inside each one.

The Sort screen in Bake'n Deck: the playlist list, and the sorted preview with Key and BPM columns

The order you are about to write, before anything is written

## How to sort a rekordbox playlist by key and BPM

1. **Export your collection as XML**
File → Export Collection in xml format. Always save to the same path, for example ~/Music/rekordbox/collection.xml.
2. **Run Sort**
In the Mac app, the Sort page sorts every playlist in place; to see one playlist's new order before anything is written, take it through the Playlist steps. On the command line, baken rbsort collection.xml sorts every playlist in place.
3. **Point Imported Library at that file, once**
Preferences → Advanced → Database → rekordbox xml → Imported Library, and select the same file. This is a one-time setup.
4. **Restart rekordbox**
The rekordbox xml tree in the left sidebar becomes a sorted mirror of your Playlists.
5. **Export to USB**
Drag a playlist from the rekordbox xml tree into your Playlists, switch to EXPORT mode, right-click → Export Playlist. The CDJ plays it in that order.

**Don't see it?** The sorted playlists live only in the `rekordbox xml` tree, not in your main `Playlists`. Switch sidebar trees.

```
# Terminal — rbsort
$ baken rbsort ~/Music/rekordbox/collection.xml
✓ Sorted 12 playlists (1480 tracks) by Key+BPM → ~/Music/rekordbox/collection.xml
$ baken rbsort ~/Music/rekordbox/collection.xml --playlist "Sets/Friday"
✓ Sorted 124 tracks in 'Sets/Friday' by Key+BPM → ~/Music/rekordbox/collection.xml
```

## Sort rules

- **Primary**: Alphanumeric key ascending, `1A → 1B → 2A → 2B → … → 12A → 12B`
- **Secondary**: BPM ascending within each key group
- Alphanumeric (`8A`) and Classic (`Am`, `F#m`, `Db`) keys sort alike, as rekordbox exports them: the command line since baken 4.2.0, Bake'n Deck for Mac since 1.2.0
- Tracks with no key sort **after** all known keys; BPM 0 sorts last within a key group
- The exported XML is sorted in place. Only the order of the track references changes; names, folders and every other byte are preserved, so re-running is a no-op
- Your rekordbox library itself is never touched; the sorted playlists appear in the separate `rekordbox xml` tree

## Frequently asked questions

### Can rekordbox sort by key and BPM at the same time?

Not in one step. rekordbox and the players sort one column at a time, and rekordbox's Renumber Track Order stores only that one-column order in the playlist. Sort by key and the BPMs inside each key stay in the order the tracks were added to the playlist. Getting both means writing a key then BPM order into the playlist itself: by hand that is two sorts and two renumbers per playlist, and Bake'n Deck's Sort does it for every playlist at once.

### Why are the BPMs scattered after I sort by key on the CDJ?

Because sorting on the player is a view. It never changes the order stored in the playlist, and the stored order is what the CDJ reads.

### Does this modify my rekordbox library?

No. Your library is never touched. Only the track order inside the exported XML changes, and the sorted playlists appear in the separate rekordbox xml tree. Names and folder structure stay as they were.

### Do cues and beatgrids survive?

Yes. Sort changes the order of the track references and nothing else. The audio files are not touched at all.

### Is it free?

The baken CLI is free and MIT licensed for macOS, Windows and Linux. Bake'n Deck for Mac is a one-time purchase on the Mac App Store, with no subscription.

## Get Sort

Bake'n Deck for Mac is on the Mac App Store. It shows the resulting order before anything is written and offers a re-sort whenever rekordbox exports the XML again. On macOS 27 it also compares rekordbox's BPM and key with what macOS hears and marks the disagreements ([how, with the numbers](https://baken.ravers.workers.dev/music-understanding)). The baken CLI is free and MIT licensed.

[Download on the Mac App Store](https://apps.apple.com/app/baken-deck/id6808813823)

[See all the tools →](https://baken.ravers.workers.dev/)

## Related guides

- [rekordbox Auto Gain: why it does not reach your CDJ](https://baken.ravers.workers.dev/auto-gain): Where the number stops, and what writing the gain into the file changes.
- [Loudness normalization for DJs: a LUFS target or a true peak ceiling?](https://baken.ravers.workers.dev/loudness-normalization): Two ways to even out levels in the file, what each changes, what each leaves to the DJ, and where rekordbox's Auto Gain fits.
- [Export rekordbox playlists to a USB stick without opening rekordbox](https://baken.ravers.workers.dev/usb-export): What a CDJ reads from the stick, how baken writes it from collection.xml, and rekordbox 7's library inconsistency warning.
- [How Headroom measures loudness and true peak](https://baken.ravers.workers.dev/measurement): In-process BS.1770-4 instead of ffmpeg loudnorm: 15x faster per file, 1,036 tracks in 20 s, with the parity numbers.
- [Apple's Music Understanding in a DJ app](https://baken.ravers.workers.dev/music-understanding): The Swift code, BPM and key against rekordbox on 100 tracks, pace as energy, vocals, speed, and the pitfalls on macOS 27.

---

Source: https://baken.ravers.workers.dev/sort
