The short version

Computers sort text one character at a time, so page10 comes before page2 because 1 comes before 2. An unpadded batch that runs past nine files will scramble in any tool that sorts plainly by name.

Three fixes, in order of durability: pad the numbers in your filenames, drag the files into position before merging, or rebuild the order from the merged file with a range selection.

You merged twelve files and got a document that runs 1, 10, 11, 12, 2, 3, 4. Nothing is missing, nothing is corrupted, and the sequence is useless. It looks like a bug and it is not one.

Why page10 comes before page2

Sorting text is not the same as sorting numbers. When a computer compares two filenames it goes character by character, left to right, and stops at the first difference.

Comparing page10.pdf with page2.pdf, the first four characters match. At the fifth, it compares 1 against 2. One sorts before two, so the comparison ends there and page10 wins. The fact that ten is larger than two never enters into it, because nothing in that comparison is treating them as numbers.

How a computer orders theseAlphabetical sort
  • page1.pdf1st
  • page10.pdf2nd
  • page11.pdf3rd
  • page2.pdf4th
  • page20.pdf5th
  • page3.pdf6th
Why your file manager looks right
Windows Explorer and macOS Finder both use natural sorting, which detects runs of digits and compares them as numbers. So the folder looks correctly ordered while the merge tool disagrees. The folder is the odd one out. Most software, most programming languages and most web tools sort plainly, and plain sorting is what you should assume you are dealing with.

Three ways to fix it

All three work. They differ in how much they protect you next time.

AnatomyWhat the merge did to your pages
Two documents12312Merged, and renumbered12345A link that pointed at "page 1" of the second filenow has to point at page 4, or it points at nothing.
A merge numbers pages in list order, so the second file's first page becomes page 4. Whatever order the list is in becomes the page order.

Pad the numbers

Rename the files so every number has the same number of digits. page01.pdf through page12.pdf sort correctly under plain alphabetical rules, because now the comparison at the fifth character is 0 against 1, which gives the answer you wanted.

This is the only fix that travels. The order is baked into the names, so it survives being emailed to a colleague, uploaded to a different tool, or opened on another operating system. If you merge batches regularly, this is the habit worth building.

Arrange them by hand

Merge tools that show the loaded files as a list let you drag them into place before combining. Load everything, arrange deliberately, then merge. This is the fastest fix for a one-off job and it requires no renaming at all. In PDFslime's Merge PDF the list is the output order: drag a row or use its arrows, and the Sort by name button reads runs of digits as numbers, so it puts page2 before page10 even without padding.

The catch is that it protects only this merge. Do the same batch next month and you will be dragging again.

Rebuild the order afterwards

If the merge has already happened and re-running it is awkward, a page list can reorder the finished document. Load the scrambled file into Merge PDF on its own and type 1,5,6,7,8,9,10,11,12,2,3,4 into its Pages box: the pages come out in the order typed. Not every tool keeps typed order. PDFslime's Split puts extracted pages back in ascending order, so use Merge for this, or drag the thumbnails in Organize PDF.

Work out the mapping by opening the merged file and writing down where each page landed. Tedious for twelve files, and the only way back when re-merging is not an option.

Padded filenames

Fix it once, permanently

  • Correct order in every tool, on every system
  • No dragging, no manual step at merge time
  • Works for scanner output if you set the pattern
  • Takes one rename pass to set up
Dragging at merge time

Fix it for this job only

  • No renaming, immediate result
  • Fine for a batch you will never repeat
  • Easy to misplace one file in a long list
  • Does not help anyone else you send the files to

When the scanner caused it

Scanner software is a frequent source of this, because it names files by an internal counter that has no relationship to the order you fed the paper in. Sheet feeders that split a batch across several files are worse, since the split points are decided by the hardware.

If the scanner lets you define a filename pattern, set one with padded numbering and the problem disappears at source. If it does not, one rename pass after scanning and before merging is the cheapest place to intervene. Scans bring other seams too, and the guide to combining scanned documents covers blank backs and sideways pages in the same pass.

Check the joins, not just the start
A scrambled merge is obvious when page one is wrong. It is much less obvious when only the last three files ended up out of sequence, which is exactly what happens when a batch crosses from single to double digits. Scroll the whole document, or at least every point where one source file ends and the next begins.

When the whole document is backwards

A completely reversed order is a different problem with a different cause. Usually the scanner fed the stack face-down, or the software was set to add each new page at the front rather than the back.

A page list handles it: type the page numbers in descending order into Merge PDF's Pages box. For a twelve page document, 12,11,10,9,8,7,6,5,4,3,2,1 gives you the document the right way round. Type each number, because a written range such as 12-1 is read as 1 to 12. Then check the scanner setting so the next batch does not come out backwards.

Number the pages once it is right
Once a merged document is in the correct order, stamping page numbers on it makes any future disorder immediately visible. It also means that if the file is ever printed, dropped and reassembled, the correct sequence is recoverable from the pages themselves.

Merge with drag-to-reorder

Arrange the files exactly as you want them before combining. Nothing uploaded, nothing tracked.

Open Merge PDF

Common questions

The follow-up questions once the cause makes sense.

01Why does my merge tool ignore the order in my folder?

Because your file manager and the merge tool sort differently. Windows Explorer and macOS Finder use natural sorting, which reads runs of digits as numbers. Most other software sorts plainly, character by character, which puts page10 before page2.

02What is the most reliable way to control merge order?

Pad the numbers in the filenames so they are all the same length: 01 through 12 rather than 1 through 12. That makes plain alphabetical sorting produce the order you want, and it keeps working in every other tool and on every other machine.

03Can I fix the order without merging again?

Yes. Load the merged file into PDFslime's Merge PDF on its own and type the order into its Pages box, for example 1,5,6,2,3,4. The pages come out in the order typed. Organize PDF does the same job by dragging page thumbnails, which is easier when only a few pages are out of place.

04My entire document is backwards. Why?

Usually the scanner fed the stack face-down, or its software inserted each new page at the front instead of the back. Type the page numbers one by one in descending order to reverse it, because a written range such as 12-1 is read as 1 to 12. Then check the scanner setting so the next batch comes out right.

05Does reordering pages reduce quality?

No. Reordering copies page objects into a new sequence without re-rendering anything. The pages are byte-identical to what they were, just listed in a different order in the page tree.

06Why did only part of my document scramble?

Because the batch crossed from single to double digit numbering. Files 1 through 9 sort correctly among themselves, and 10 onwards insert themselves after 1. If your batch had nine or fewer files you would never have seen the problem.