func compareTags()

in internal/cssc/cssc.go [319:344]


func compareTags(tag1, tag2 string) bool {
	// If tag1 and tag2 ends with incremental or floating pattern, then extract suffix based on last occurrence of "-" and compare the suffixes
	if endsWithIncrementalOrFloatingPattern(tag1) && endsWithIncrementalOrFloatingPattern(tag2) {
		tag1Index := strings.LastIndex(tag1, "-")
		tag2Index := strings.LastIndex(tag2, "-")
		var tag1Suffix, tag2Suffix string
		if tag1Index != -1 {
			tag1Suffix = tag1[tag1Index+1:]
		} else {
			tag1Suffix = tag1
		}
		if tag2Index != -1 {
			tag2Suffix = tag2[tag2Index+1:]
		} else {
			tag2Suffix = tag2
		}
		// Compare the suffixes
		if isNumeric(tag1Suffix) && isNumeric(tag2Suffix) {
			aNum, _ := strconv.Atoi(tag1Suffix)
			bNum, _ := strconv.Atoi(tag2Suffix)
			return aNum < bNum
		}
	}
	// Fallback to lexicographic comparison
	return tag1 < tag2
}