to sort an array