If I have a wallet that currently stores x amount of NFT's and I make a validator script that provides one NFT from that wallet in exchange for ADA what would I call to make sure 1 unique NFT goes out to each caller of the said validator script? Specifically how would the validator script know which NFT to give out? Is there a way to sort out metadata of NFT's using script context and pick the next NFT to send out by its number order?
There are onchain validator scripts available like this one, which describe nicely how it can be done.
The way that my vending machine does it is that I store all of the total NFT collection in a MongoDB. Then, when my script sees a sale UTXO come into a wallet, it queries the MongoDB for any NFT that is still 'available' and pulls them all down into an array. I then shuffle the array and mint the one in the  spot. Finally, I mark the NFT as sold in MongoDB.