GE interview question

puzzle loop sort thing I think