trying to simplify output for the command yum list installed in RHEL 7.6

Hey peeps, 

I’m trying to write a script to compare installed packages between computers.  I have a command for rpm installed packages that gets rid of duplicate names, lists everything in alphabetical order and ignores numbers, but I’m not sure how to do the same thing with the yum list installed command.  The command for rpm query is 

rpm -qa --queryformat=’%{NAME}\n’ | sort | uniq > comp1.txt

If anyone knows a similar set of options for the yum command that would produce a similar output so that I can easily run the diff command against two files from 2 different computers so that I can tell which packages are installed by yum and what the other computer is missing, I would be very grateful for your response.

Thank you!