Toptal interview question

Sort the array with its special order