cfpb/regulations-parser — pull request #226 by cmc333333 (2014-03-12 23:34:22+00:00)
Title: Don't resort nodes upon insertion

When modifying the node tree, as nodes are added, they must be inserted into their parent's "children" list. Previously, we'd append to the end of that list and then resort.

That strategy works well when the original list is sorted, but causes order errors when the original list was only *mostly* sorted (as with regulations). This patch uses `bisect` (thanks for the suggestion @khandelwal) to insert "in place". The solution won't work for an arbitrary list, but given our *mostly* sorted lists, it works well.

In addition, always place interpretation paragraphs before sub-interpretations (e.g. "1234-11-Interp-1" before "1234-11-1-Interp").