A sorting robot would probably be implemented as an in-game item. It does not have to be an item, but let us assume it is. CCP seems to implement most functions as items (i.e., to organize your hangar you have to use a physical container to get the effect of a "folder").
A sorting robot is a special kind of container. Indeed, it acts as a container: you can put stuff in it just like a freight container. However, its intended use is to allow you to program it to automatically collect and package stuff. To this end, it has a fairly extensive set of parameters you can set. (A UI would have to be created for this.) The parameters are:
- a multiset of items (a multiset is a set where items can appear multiple times)
- a "where to search" variable: top hangar only, only below the top hangar, the entire hangar
- a "use market deliveries" flag
- an "auto repeat" flag
- a "mail notification" flag
- a priority, perhaps 1 to 5
- a destination (optional)
- a name string (optional)
The "where to search" is fairly self-explanatory. The sorting robot searches for and takes stuff only from the places you specify here. In addition, it will take stuff out of your corp's "Market Delivieries" hangar if that flag is set.
The multiset is what the robot is attempting to find and package. The set should allow any kind of item, and any number of each type. So, for example, you might set the robot to assemble the exact minerals you need to build 10 Catalysts, which for my Jita alt are as follows: Tritanium - 514870; Pyerite - 145200; Mexallon - 63620; etc.
The set of items may be inputted via drag and drop, then right-click on a desired item and set its amount. However, since the intended function is to make assembling sets of stuff for manufacturing, the more common use is to program the robot using a blueprint. This works as follows: at any time you can right-click on the robot and there should be an item "Program from Blueprints". If you select it, it displays a list of "blueprints" and multiplicities that the robot is currently using. (A "blueprint" here is not an actual blueprint, but a transcription of a blueprint's information.) The UI should allow the user to change the multiplicity, and/or remove a blueprint entirely. There should also be an "add blueprint" function. When you select it, it displays the Assets interface and tells you to find the blueprint you want to add. You find it and select "Add this blueprint" or whatever; then that material inputs for that particular blueprint (as it currently is, for the current character) are recorded and the blueprint added to the list of blueprints that the robot has. Note that each "blueprint" that the robot has a record of is simply a multiset itself; if the character's skill changes, or the (actual) blueprint is improved, then robot's copy may be out of date.
Sorting robot operation uses the robot's contents, and works as follows. If the robot has enough of a particular item already inside it (remember it is a container), it does not look for that item. Otherwise, it looks where it has been told to look (that is, in "where to search"). If there are multiple sorting robots active in a hangar, they use their "priority" variable to determine the order in which they will search.
If the robot finds an item (or stack of items) it is looking for which is packaged, it moves the item inside itself. If the item is not packaged, the robot attempts to package it and then move it. (If it cannot be packaged, the robot does nothing and the item should not be moved.)
Once the robot has the full multiset of stuff inside it that it is looking for, it wraps the stuff up into a package similar to a courier package. The package is placed in the top level hangar. If the "mail notification" flag is set, mail is generated to the character to notify him or her of the new package. If the optional destination has been set, it should be set on the package. (This destination should be automatically used for destination if the package is sent using a courier contract.) If the optional name string has been set, the package should be named that. Otherwise the name should be that of the sorting robot. For example, you might name a sorting robot "Minerals for 10 Catalysts"; that name would be replicated on each package that the robot creates.
Finally, according to the "auto repeat" flag, the robot either keeps shuts itself down (it must be restarted manually) or not. If not, then it will automatically start attempting to make another package.