Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Can miners freely choose the order of transactions within a block or are there any restrictions like the transactions need to be sorted by gas price?
For the most part. The only stipulation is that transactions from the same address must be executed by ascending nonce - e.g. if I send 2 transactions, one with nonce 3 and one with nonce 4, the miner must order the nonce 3 tx before the nonce 4 tx.
Required, but never shown