Schbang Interview Question

Logic behind sorting an array