Interesting bug... I fixed it in https://netvor.sk/trac/arcomage/changeset/692. Changes should be applied soon.
I must give credit to Fithz Hood, since his debug information is very clear. Indeed, this bug occured only when you have 10 or more cards in discard pile. It was caused by incorrect ordering mechanism.
You see cards were sorted by their position marker. The marker looks like this: kN, where N is the position of the discarded card.
Let's assume N = 5. The order would look like this: k5, k4, k3, k2, k1. Which is correct. However, when having N > 9, then the order is incorrect. For N = 12, the order would look like this: k9, k8, k7, k6, k5, k4, k3, k2, k12, k11, k10, k1. This is a standard lexicographical order, because the markers are strings, not numbers.
So, I only changed markers to numbers and selected a standard number ordering :)
Btw. I noticed that played cards are displayed in the descending order, so the last card played is the first. But, the cards discarded by card effect, are displayed in ascending order. Shouldn't both mentioned card piles use the same order mechanism?