diff --git a/langext/compare.go b/langext/compare.go index 5573f5d..91a8cac 100644 --- a/langext/compare.go +++ b/langext/compare.go @@ -61,3 +61,43 @@ func CompareArr[T OrderedConstraint](arr1 []T, arr2 []T) bool { return false } + +func CompareString(a, b string) int { + if a == b { + return 0 + } + if a < b { + return -1 + } + return +1 +} + +func CompareInt(a, b int) int { + if a == b { + return 0 + } + if a < b { + return -1 + } + return +1 +} + +func CompareInt64(a, b int64) int { + if a == b { + return 0 + } + if a < b { + return -1 + } + return +1 +} + +func Compare[T OrderedConstraint](a, b T) int { + if a == b { + return 0 + } + if a < b { + return -1 + } + return +1 +}