Check if array contain values before sorting them