Proper arrangement of axonal projections into topographic maps is crucial for brain function, especially in sensory systems. An important mechanism for map formation is pretarget axon sorting, in which topographic ordering of axons appears in tracts before axons reach their target, but this process remains poorly understood. Here, we show that selective axon degeneration is used as a correction mechanism to eliminate missorted axons in the optic tract during retinotectal development in zebrafish. Retinal axons are not precisely ordered during initial pathfinding but become corrected later, with missorted axons selectively fragmenting and degenerating. We further show that heparan sulfate is required non-cell-autonomously to correct missorted axons and that restoring its synthesis at late stages in a deficient mutant is sufficient to restore topographic sorting. These findings uncover a function for developmental axon degeneration in ordering axonal projections and identify heparan sulfate as a key regulator of that process.