Move long commands and multiline text into heredocs

Uses `sort` to perform version comparisons.