1. The Alim.
2. The best reciter of the Qur’an (the Qari)
3. The most pious.
4. The oldest.
5. The most virtuous in character.
6. The most handsome.
7. The one of most noble birth.
8. The one with the sweetest voice.
9. The one with the cleanest clothes.
It everyone is equal then you can draw lots or the people can vote and the majority wins. Some books of fiqh say the one with the prettiest wife. Also the regular imam has a right to lead the namaaz over a visiting imam from another masjid even if the visiting imam is more qualified to lead the namaaz. The owner of the house has more right to lead the jamaat in his house than anyone else.