A little set theory. A lot less work.
Only in A and Only in B show the differences. In both is the intersection: items the lists share. All unique is the union: every distinct item across the two lists.
How are duplicates and spaces handled?
Results contain each matching item once. Empty items are skipped. Comparison options determine what counts as a match; results preserve the first original spelling, using List A’s version for shared items. Output case only changes the displayed results.