Anvil optimizer

Pick an item and the enchanted books you have. You get the order that costs the fewest levels in total, with no step reaching Too Expensive (40 levels).

Item
Books (one per enchantment)
Already on the item (leave empty for a new one)
Cheapest order