In this theoretical study we discuss a novel method for sorting ring polymers according to their topological, knotted state. The proposed approach harnesses the rich dynamical behaviour of polymers confined inside spatially-modulated nanochannels. The longitudinal mobility of the rings is shown to have two key properties that are ideally suited for knot sorting. First, at fixed topology, the mobility has an intriguing oscillatory dependence on chain length. Second, the mobility ranking of different knot types is inverted upon increasing the chain length. We show that this complex interplay of channel geometry, chain length and topology can be rationalised within a simple theoretical framework based on Fick-Jacobs's diffusive theory. The results and the interpretative scheme ought to be useful for designing microfluidic devices with optimal topological sorting capabilities.