From 0652bf22dc42d40aafafcd7706d7ced055e95fa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Wed, 24 May 2023 21:32:00 +0200 Subject: [PATCH] v0.0.119 --- langext/compare.go | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) 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 +}