I drew the animation in GoodNotes on my iPad, and exported the images as a multi-page pdf. I used ImageMagick to convert the pdf to an animated gif with the following command:

1
convert -alpha deactivate -verbose -delay 100 -loop 0 -density 300 merge-sort.pdf merge-sort.gif