<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _rank_results(results: List[Dict], method: SimAlgorithm) -> List[Dict]: """ Ranks results - for phenodigm results are ranks but ties need to accounted for for other methods, results need to be reranked :param results: Results from search_by_attribute_set()['results'] or compare_attribute_sets()['results'] :param method: sim method used to rank results :return: Sorted results list """

        # https://stackoverflow.com/a/73050
        sorted_results = sorted(
            results, reverse=True, key=lambda k: k[OwlSim2Api.method2key[method]]
        )
        if len(sorted_results) > 0:
            rank = 1
            previous_score = sorted_results[0][OwlSim2Api.method2key[method]]
            for result in sorted_results:
                if previous_score > result[OwlSim2Api.method2key[method]]:
                    rank += 1
                result['rank'] = rank
                previous_score = result[OwlSim2Api.method2key[method]]

        return sorted_results