Topological order

The idea is to sort addins in a topological order. Each addin can define one of five things for _order_:
* `>X` - I must be immediately after the addin with id X

* `>>X` - I must be somewhere after the addin with id X (but not necessarily immediately) 

* `<X`- I must be immediately before the addin with id X

* `<<X` - I must be somewhere before the addin with id X (but not necessarily immediately) 

* `Number` - A numerical order which is used if none of the above is applicable


ok, this is a bit longer and i'm tired so i'll have a look at it more in depth tomorrow.

generally, it looks like you're not using the symmetric qualities of your situation (but i could be wrong).
i would externalize one function to handle the case of X < Y, and then if i encountered the case of X > Y i would convert to Y < X and continue processing.

additionally, i would suggest using some sort of tokenizer or simple parser to help you. using this whole index here index there nested ifs is just hiding the entire logic behind a sea of irrelevancies.