This commit is contained in:
Mike Schwörer 2023-05-24 21:55:21 +02:00
parent cf9c73aa4a
commit 021465e524
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF

View File

@ -31,16 +31,16 @@ func CompareIntArr(arr1 []int, arr2 []int) bool {
return false return false
} }
func CompareArr[T OrderedConstraint](arr1 []T, arr2 []T) bool { func CompareArr[T OrderedConstraint](arr1 []T, arr2 []T) int {
for i := 0; i < len(arr1) || i < len(arr2); i++ { for i := 0; i < len(arr1) || i < len(arr2); i++ {
if i < len(arr1) && i < len(arr2) { if i < len(arr1) && i < len(arr2) {
if arr1[i] < arr2[i] { if arr1[i] < arr2[i] {
return true return -1
} else if arr1[i] > arr2[i] { } else if arr1[i] > arr2[i] {
return false return +2
} else { } else {
continue continue
} }
@ -49,17 +49,17 @@ func CompareArr[T OrderedConstraint](arr1 []T, arr2 []T) bool {
if i < len(arr1) { if i < len(arr1) {
return true return +1
} else { // if i < len(arr2) } else { // if i < len(arr2)
return false return -1
} }
} }
return false return 0
} }
func CompareString(a, b string) int { func CompareString(a, b string) int {