On-Chip Single-Photon Sifter