Fix issue #2. Sort all-references and find virtuals with definitions first