Help to understand a script

Hello world! Can someone please explain me how this code works? I'ts supposed to find words in a dictionary and show the anagrams of the words.

    {
    part = word2key($1)  
    data[part][$1] = $1  
}


function word2key(word,     a, i, x, result)
{
    x = split(word, a, "")
    asort(a)

    for (i = 1; i <= x; i++)
        result = result a

    return result
}
END {
    sort = "sort"
    for (part in data) {
        nwords = asorti(data[part], words)
        if (nwords == 1)
            continue

        for (j = 1; j <= nwords; j++)
            printf("%s ", words[j]) | sort
        print "" | sort
    }
    close(sort)
}

Going to be difficult without the complete code...