The drawback to FIFO based sorting is that things can get into the wrong lanes simply because one of several photocells has been pulsed one too many/few times, getting the FIFO length out of sync with reality. Once the system is out of sync, and if no one's looking, you can have a real mess real quick.
I have rewritten several sorting systems to use position based tracking, so that the PLC knows the position of each object in transit.
Done this way, you only really depend on one photocell to keep the sorting straight. (It is easy to detect one flaky eye and automatically stop the line when it acts up.)
In the logic, there are several different ways to abstract the concept. Here I have one in which, there are four short conveyors involved and no more than six or eight boxes between the barcode reader and the last diverter. So, I keep track of each box position as a floating point value representing "inches past PExxx". Each scan, I update my array of boxes in progress, and when one of them is within the "window" to activate a diverter and it's ID code matches, I trigger the diverter.
If the conveyor is really long and there are many more pieces in transit, then I will "map" the conveyor with a data table, so that the ID code for the product gets dropped into the data table at an index representing the position of the whole conveyor. Then the lane entry and exit points are calculated as offsets from the rolling position pointer. The data does not move around, only the pointer representing the end of the belt. In software, this is very efficient and still reliable.
The concept can be daunting at first, but it is really not any harder to set up the logic than it is with FIFOs but the results are nearly bulletproof.
When I started on my last one, I was told that it is imperative that we never send the wrong box down any of the lanes, and my new logic accomplishes that where as the FIFO stuff I replaced would have to be cleared and reset at least once every couple of days. That clearing and resetting required operators to manually move boxes around and stop the flow of product too, so they really like the fact that it never misses a beat any more.
My 2 cents,
Paul