The Polkdadot wiki says in Learn > Basics > Transaction Fees:
Block producers prioritize transactions based on each transaction's total fee. Since a portion of the fee will go to the block producer, producers will include the transactions with the highest fees to maximize their reward.
Does the weight of the transaction (or any other factor) play any role in prioritization? It seems counterintuitive that a large batch transaction (which naturally produces higher fees) is prioritized over smaller transactions regardless of their weight.