Improve efficiency of Canonical Ordering Algorithm
Merge pull request #1 from dropbox/ordering

Improve efficiency of Canonical Ordering Algorithm