Not really an awk guy: AWK Arrays Explained with 5 Practical Examples (link removed)
bash does string-addressed-containers, too, closer to ksh, which I do not think went there. Also, ksh93 does associative arrays, same thing, and is often installed as dtksh or similar:
Help -
Alternatively, you could chop the input up and annotate it for a sort, and reformat the sort output, with the elements in convenient order. For instance, you can write the file# to the sort prefixed with A and the item# parts as lines prefixed with B. In the bad old days, sort was the trick to this sort of problem, when there was tiny ram and much tape drive! COBOL has embedded sort, which can be invoker with a file or routine as input and as output.