Fix imenu indexing: Use the match data early

The match data should be used early, before any function call, because
no function can be expected to save the match data.  Notably,
syntax-ppss does not save the match data, which broke imenu generation.
Fix submenu ordering in Imenu