def get_latest_results(self):
        """
        Gets latest results for the ladder
        """
        results = {}
        for result in self.result_set.filter(ladder=self).order_by('-date_added')[:10]:  # [:10] to limit to 5

            try:
                opponent = self.result_set.filter(ladder=self, player=result.opponent, opponent=result.player)[0]
            except __HOLE__:
                continue  # this exception happens if result does not have opponent
            player_opponent_index = ''.join(unicode(e) for e in sorted([result.player.id, opponent.player.id]))
            try:
                if results[player_opponent_index]:
                    continue
            except KeyError:
                results[player_opponent_index] = {'player': result.player, 'player_result': result.result,
                                                  'opponent_result': opponent.result, 'opponent': opponent.player,
                                                  'date_added': result.date_added}

        ordered_results = {}
        i = 0
        for key in sorted(results, key=lambda x: (results[x]['date_added']), reverse=True):
            ordered_results[i] = results[key]
            i += 1

        return list(ordered_results.items())
dataset/ETHPy150Open jzahedieh/django-tennis-ladder/ladder/models.py/Ladder.get_latest_results