"When a hopper is connected to an object to its side (for example a chest) and there is a hopper directly underneath it, items in the hopper will 'leak' to the underlying hopper. However, if an even number of the same item falls into the hopper at the same time, half will go to bottom hopper and the other half to the object the first hopper is connected to. If an odd number then the extra one will go into the bottom hopper, as it takes priority. When that bottom hopper is full the items will then be stored straight away in the object to which the first hopper is connected."
perhaps this could be exploited here. Connect a hopper to a junk chest, put another one beneath with each slot having 1 of whatever desired material, so it can only hold what you want. Perhaps figure out some way to dump the junk chest back into the input. Each time it sorts, there's a 50/50 chance that you'll get what you want in the second hopper, so if you run everything through multiple times, you should get it eventually. Similar to (and as inefficient as) a bubble sort algorithm on a computer, but it might get you what you need.