I think I've solved the sorting and dispensing problem after making several iterations, see my post entitled "Pharmaceutical dispenser" which I uploaded on Sunday 7th, but which (strangely) hasn't yet appeared on the daily email feeds.