return sorted lists of declarations and defintions (and references)