A recent XCode update broke quite a bit of native code compilation, try this:
Add ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future
to whatever you were running above. It looks like the Gitlab instructions are installing it using the system Ruby, so try this:
sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install version_sorter