Schbang interview question

Logic behind sorting an array