Since TX fees go to miners, they are incentivized to pick the transactions with the largest "fee per size" to include first to maximize their profit (though they aren't required to do so).
So basically you can envision all transactions as a stack, with the highest fees at the top. Once a block is found, it takes the top ~1MB worth of transactions, and the cycle repeats. [0] is a good visual representation of this.
Unfortunately this means there isn't an easy way to determine what fee will absolutely get you included in a block before it's mined, since if thousands of transactions show up with higher fees than yours after you (but before a block is mined) yours might not make it in the next block (even if your fee was the highest when you made the transaction).
It's a tough problem to solve, but there are some solutions being worked on to help solve this problem for the vast majority of bitcoin transactions.