Toptal Interview Question

Sort the array with its special order