def _get_sorted_methods(self, methods):
if not methods:<EOL><INDENT>return methods<EOL><DEDENT>def _sorted_methods_comparison(method_info1, method_info2):<EOL><INDENT>"""<STR_LIT>"""<EOL>def _score_path(path):<EOL><INDENT>"""<STR_LIT>"""<EOL>score = <NUM_LIT:0><EOL>parts = path.split('<STR_LIT:/>')<EOL>for part in parts:<EOL><INDENT>score <<= <NUM_LIT:1><EOL>if not part or part[<NUM_LIT:0>] != '<STR_LIT:{>':<EOL><INDENT>score += <NUM_LIT:1><EOL><DEDENT><DEDENT>score <<= <NUM_LIT> - len(parts)<EOL>return score<EOL><DEDENT>path_score1 = _score_path(method_info1[<NUM_LIT:1>].get('<STR_LIT:path>', '<STR_LIT>'))<EOL>path_score2 = _score_path(method_info2[<NUM_LIT:1>].get('<STR_LIT:path>', '<STR_LIT>'))<EOL>if path_score1 != path_score2:<EOL><INDENT>return path_score2 - path_score1<EOL><DEDENT>path_result = cmp(method_info1[<NUM_LIT:1>].get('<STR_LIT:path>', '<STR_LIT>'),<EOL>method_info2[<NUM_LIT:1>].get('<STR_LIT:path>', '<STR_LIT>'))<EOL>if path_result != <NUM_LIT:0>:<EOL><INDENT>return path_result<EOL><DEDENT>method_result = cmp(method_info1[<NUM_LIT:1>].get('<STR_LIT>', '<STR_LIT>'),<EOL>method_info2[<NUM_LIT:1>].get('<STR_LIT>', '<STR_LIT>'))<EOL>return method_result<EOL><DEDENT>return sorted(methods.items(), _sorted_methods_comparison)<EOL>
Get a copy of 'methods' sorted the way they would be on the live server.

        Args:
          methods: JSON configuration of an API's methods.

        Returns:
          The same configuration with the methods sorted based on what order
          they'll be checked by the server.