The five that matter
Sharpness V (raw damage), Looting III (more drops), Sweeping Edge III (crowd hits, Java only), Unbreaking III (durability) and Mending (self-repair from XP). Knockback is mostly a downside on swords — it pushes mobs out of your follow-up swing.
Anvil order saves levels
Combine enchantments into books first, then merge books onto the sword in one pass. Each anvil operation multiplies the item’s prior-work penalty, so the cheapest path is: books combined separately (Sharpness III + Sharpness IV = V), then all books onto the blade in a single final anvil use. Never swing-purchase small upgrades one at a time.
Where to get the books
Librarian villagers sell enchanted books for emeralds — break and replace their lectern until the right offer appears. Fishing, loot chests and the enchanting table itself fill the gaps. Mending is the rarest and the only one worth hunting specifically: it makes the sword effectively immortal.
Netherite timing
Upgrade the sword to netherite after enchanting — the smithing-table upgrade preserves all enchantments and does not reset the anvil penalty, so there is no reason to re-buy books.