4 the sorting logic my cc based "ae" system needs is pretty much done. The script can't use the top or bottom to sort to you but it can do some pretty advanced stuff due to it using functions to check where something goes and it having a fallback function if it can't find an function belonging to the exact item it wants to route.
(This fallback function can be used to make a default route, or to set up very broad rules with sting.find() to for example put every item that has the word "ore" in its id to a certain route. Or pretty much everything else you can think of. Though I don't think turtle.getItemDetail() gives access to nbt data (only the id, amount and damage value)