There's a lot of cases where it seems arbitrary which tiles get combined. Is there a rule for priority?
Yes there is a rule, tiles are merged backwards from direction you slide.