  Sorting spatial optical modes is a key challenge that underpins many
applications from super-resolved imaging to high-dimensional quantum key
distribution. However, to date implementations of optical mode sorters only
operate on specific sets of modes, such as those carrying orbital angular
momentum, and therefore lack versatility with respect to operation with an
arbitrary spatial basis. Here, we demonstrate an arbitrary spatial mode sorter
by harnessing the random mode mixing process occurring during light propagation
in a multimode fibre by wavefront shaping. By measuring the transmission matrix
of the fibre, we show sorting of up to $25$ transverse spatial modes of the
Fourier, Laguerre-Gaussian and a random basis to an arbitrary set of positions
at the output. Our approach provides a spatial mode sorter that is compact,
easy-to-fabricate, programmable and usable with any spatial basis, which is
promising for quantum and classical information science.
