Result checking before sorting tags array