Logic to sort the tags was wrong.