def METHOD_NAME(self, query, results):
    exact_matches = []
    word_matches = []
    partial_matches = []
    for x in results:
        name = x[1].lower()
        generic = x[3].lower()
        company = x[4].lower()
        words = f"{name} {generic} {company}".split()
        if name == query:
            exact_matches.append(x)
        elif query in words:
            word_matches.append(x)
        else:
            partial_matches.append(x)
    return exact_matches + word_matches + partial_matches