Where is compare_spells (and similarly sort_spells) ever used?  I don't see it actually called from another function in any of the source.  I can't tell if it's for players or for mobs, so I don't know if GET_PLAYER_SKILL is appropriate.  Certainly GET_SKILL would work universally?