updated party sorting, now done by number of seats then votes for ties, some code refactoring as well