I can't see any simple way to do this. You could try setting the custom value of heroes to 1 if strength, 2 if agility, and 3 if intelligence, and then go from there.
Actually to my understanding even some melee heroes have greater X attribute than their main one.
I ran into this problem once, the only way I found was to abuse point value. So I changed point value in object editor so intelligence heroes had 1 , strength heroes 2 and agility heroes 3. So I compared the unit's point value
Sorry for a bit of thread necromancy, but can someone please go into a bit more detail as to how point value works and how to retrieve it with triggers?