Python recursive function that receives list of strings, and returns a nested list of anagrams
I think a much simpler approach would be beneficial to you here, as well as if you were to utilize a dictionary to hold the results as you go along. The below code does not make use of recursion though, so if you were trying to learn about recursion in python then this would not help. But if you're just trying to learn what a simple and pythonic function to solve this problem would look like then I think this will help you. Notably it is much less code, easier to reason about, and does not make use of global variables.
def sort_anagrams2(list_of_strings):
    result = {}

    for string in list_of_strings:
        sorted_string = &quot;&quot;.join(sorted(string))

        if sorted_string in result:
            result[sorted_string].append(string)
        else:
            result[sorted_string] = [string]

    return list(result.values())