Debugging in index facility

This change: 
allows the index material to gather all the subentries for a single top level entry together
properly alphabetizes the subentries
correctly merges an entry with a reference and an entry without a reference