Transaction order in a block matters, since that's the order those transactions are executed and take effect on the state of the EVM. But what or who decides the order of transactions? Is it hard-coded based on the price of gas paid by the sender, so that TXs with higher gas paid would be ordered first? Or is it completely up to the miner to decide the order of transactions in a proposed block?
It depends, really. Some miners on the Ethereum chain, like Ethermine, use non-conventional ordering for their benefit, aka they generally don't do the by-gas sort. Other miners can choose to sort by gas and nonce, others can choose to sort by gas and first-seen-time, others can first sort by gas and then randomize the order, others can sort by gas first and then put the "greatest" sender addresses at the top or bottom, which is basically converting an address to a 160-bit integer and working with those values.
Most other POA networks that run on the EVM, like BSC or Polygon, generally sort by gas and first-seen-time.
The order of transactions (we are talking about transactions with the best gas price) is decided by the miners to make the most profit out for them. To find out more about the subject google keywords
Miner Extractable Value (MEV)
For example, if you send a transaction to buy some large amount of tokens, the miner will insert his own transaction to buy this token before you, amd make some money. So, the order of transactions "will depend" so to speak. They all have their own custom algorithms and nobody knows how they maximize profits, this is part of the dark forest (also keyword) of Ethereum