I have a three lane sorter that uses logic similar to what Peter Describes. I have a rolling Queue that represents the contents of the conveyor. The barcode, destination lane assigned, and product weight are all in their own files. I only have at the most 6 or seven boxes in transit between the barcode reader and the last diverter. My conveyor runs about 150 fpm and sorts about 28 boxes per minute. I did not bother with an encoder for such a slow sorter, I have more than two whole seconds to pop the pneumatic stop plates down in front of the box, and operate a kicker cylinder to send them down a lane.
I simply measured the belt speed with a hand tach, and did some math since my sort belt is on a contactor. I eyeballed the accel and decel times, and wrote logic to account for the rare occasion when the belt stops due to a jam up. I put the sorting (position tracking) logic in an STI routine to update those 6 or 7 ( I have room for up to twenty) boxes in transit. I did not shift any data, I just had a handful of pointers and flags. One for the highest indice value of a box in transit, and another for the lowest. I would loop through those in order to compare their position value (floating point) with the windows for kikcers, barcode readers, etc.
When a box was successfully diverted, it was no longer updated by simply setting it's position value to a range outside of all of the working windows. The stop cylinder and kicker are driven by position offsets from the barcode reader. Once adjusted, you never really have to mess with these tunable offsets for each station. This method only relies on accuratly estimated deltas of the position of six or seven values. There is a lot of indirect addressing, and there are two loops in my logic, but it cannot get out of sequence, never has to be "cleared" like the classic and more fallible cascading FIFOs driven by photoeyes. As long as I get a good barcode read (even the trigger for the barcode reader is based on a position offset window), and the very first photo eye works, the system is bulletproof.
Absolutely use an encoder if you can, that will save a bit of math for estimation and can handle stops, jogs, and reverse while retaining tracking position information accurately at much higher speeds than what I have going on.
I despise FIFO based shift register systems that can get out of sequence. This is probably because I use to stack green tires for a living and deal with all the problems that approach can cause for the labor force dealing with the product by hand when there is a sequence error.