If both transactions make it into the same block you can't really discern which transaction came first, so with the targeted average block interval being 10 minutes you have a bit of leeway with how fast your bot has to react.
You don't really have a guarantuee that both transaction make it into the same block though or that your transaction gets confirmed earlier, however having a higher transaction fees increases the chance of your transaction being prioritized by miners.