Added method to sort array