diskutil moving partitions into order for merging
Though you can't move the partitions, you will be able to merge both partitions. You have to convert disk0s1 to a CoreStorage Logical Volume Group, then add disk0s4 as a second CS Physical Volume to the existing CS LVG and expand the Logical Volume in the existing CS LVG to the expanded CS LVG. CS is available in older OS X versions but adding PV to existing LVG is only working reliably in OS X 10.9 and newer.

mergeThis   disk0s1
leaveAlone  disk0s2
leaveAlone  disk0s3
withThis    disk0s4

mergeThis   disk0s1 &gt; LVG' &gt; PV1 (disk0s1) &gt; LVF' &gt; LV' (disk1)
leaveAlone  disk0s2
leaveAlone  disk0s3
withThis    disk0s4

mergeThis   disk0s1 &gt; LVG &gt; PV1 (disk0s1) &gt; LVF' &gt; LV' (disk1)
leaveAlone  disk0s2
leaveAlone  disk0s3
withThis    disk0s4 &gt; LVG &gt; PV2 (disk0s4)

mergeThis   disk0s1 &gt; LVG &gt; PV1 (disk0s1) &gt; LVF &gt; LV (disk1)
leaveAlone  disk0s2
leaveAlone  disk0s3
withThis    disk0s4 &gt; LVG &gt; PV2 (disk0s4) &gt; LVF &gt; LV (disk1)


The content of disk0s4 will be erased. The content of disk0s1 will be preserved as disk1 and disk1 has finally the ~size of disk0s1 + disk0s4.



CoreStorage is a logical volume manager, which is an additional layer between device/partition and a volume.

A Logical Volume Group is based on one or several Physical Volumes (which can be one or several physical devices/partitions) and may contain one or several Logical Volume Families/Logical Volumes.

In OS X it's usually used to manage FileVault and Fusion Drives,