The implementation of ActionQueue.InsertActionSorter has gone through quite some back and forth. Currently it settles on some bubble sorting algorithm which has following drawbacks:
- time complexity is unnecessarily high (i.e O(n^2));
- no reliable way to detect circular dependency;
- code readability is bad, which leads to difficult maintainability;
Topological sorting is the canonical solution for such ordering in face of inter dependencies. It will solve all the above issues ending up with elegant, quick and maintainable implementation. |