Sorting array properly