My question is what is the algorithm that a miner picks a transaction from the mempool to include it to a block?
They prioritize transactions based on their fee rate. The more fee rate you use for your transaction, the faster it can be included in the blockchain.