That is the point of programming: you can do almost anything.
The problem is that YOU have to make it do anything.
With your card game, that means you have to use some kind of code number and associate them with images and rules. Those values are static (such that card #12 would always retain its image and rule reference). Then, each card also has a dynamic set of attributes. If card #12 is at position 5 in the deck, that is the value its ‘position’ attribute has. If it is in the discard pile, then it would be -99 (for instance).
Discarding a card would therefore replace its position in the deck value from 5 (for instance) to -99.
Then you would have a internal deck position counter that says which position is now at the top of the pile (it would start with 1, and by the time you reach the 5th card, that position would be 5, and all the cards with position below 5 would have now been discarded (with values set to -99) or in the had of player 1 (position value -1), player 2 (position value -2).
The point is that you make a system that would work. And you program accordingly.