Array and sorting problem