1. It's not impossible, but it's impractical. You need multiple containers all of a sudden, and these can't be fixed-size containers because not everyone consumes the same proportion of any given material.
2. People are going to sort things wrong, meaning you need to check/re-sort at the processing plant.
3. How difficult of a challenge is it to build sorting machines, anyway? Are you going to tell me self-driving cars are coming soon but we can't build machines to handle this? If it really is too hard, have regulations put in place so that some machine-readable material tag be put on all packaging.
4. I think this is a good domain for regulators to step in. Tax things that are hard to recycle, and encourage packaging that is easy to recycle or biodegradable. Keep in mind, glass containers are recyclable and also reusable, meaning you can just clean and refill them at the factory, which is more energy-efficient than melting everything. No new technology needed, just go back to selling milk, sodas, etc. in glass jugs.