Pergunta de entrevista da empresa General Motors (GM)

I was given a simple array sorting challenge