Ananda, there are these 4 purifications of giving (catu dakkhiṇa,visuddhi). What are the four?
(1) There is, Ānanda, the gift that is purified on account of the
giver, but not the recipients.
(2) There is, Ānanda, the gift that is purified on account of the
recipients, but not the giver.
(3) There is, Ānanda, the gift that is purified on account of neither
the giver nor the recipients.
(4) There is, Ānanda, the gift that is purified on account of both
the giver and the recipients.
(1) And how, Ānanda, is the gift purified on account of the giver, but
not the recipients? Here, Ānanda, the giver is morally virtuous, good
by nature, but the recipients are immoral, bad by nature. Thus,
Ānanda, is the gift purified on account of the giver, but not the
recipient.
(2) And how, Ānanda, is the gift purified on account of the
recipients, but not the giver? Here, Ānanda, the giver is immoral, bad
by nature, the recipient is morally virtuous, good by nature. Thus,
Ānanda, is the gift purified on account of the recipients, but not the
giver.
(3) And how, Ānanda, is the gift purified on account of neither the giver nor the recipients? Here, Ānanda, the giver is
immoral, bad by nature, and the recipients are immoral, bad by nature.
Thus, Ānanda, is the gift purified on account of neither the giver nor
the recipients.
(4) And how, Ānanda, is the gift purified on account of both the giver
and the recipients? Here, Ānanda, the giver is morally virtuous, good
by nature, and the recipients, too, are morally virtuous, good by
nature. Thus, Ānanda, is the gift purified on account of both the
giver and the recipients.”
These, Ananda, are the 4 kinds of purification of giving
-Dakkhina Vibhanga Sutta
So, yes it is more meritorious to give to someone more virtuous. The best scenario is if both the giver and recipient are virtuous.