  Sorting quantum fields into different modes according to their Fock-space
quantum numbers is a highly desirable quantum operation. In this Letter, we
show that a pair of two-level emitters, chirally coupled to a waveguide, may
scatter single- and two-photon components of an input pulse into orthogonal
temporal modes with a fidelity $\gtrsim 0.9997$. We develop a general theory to
characterize and optimize this process and observe an interesting dynamics in
the two-photon scattering regime: while the first emitter gives rise to a
complex multimode field, the second emitter recombines the field amplitudes and
the net two-photon scattering induces a self-time reversal of the pulse mode.
The presented scheme can be employed to construct logic elements for
propagating photons, such as a deterministic nonlinear-sign gate with a
fidelity $\gtrsim 0.9995$
