Skip to content

Commit cf4e11b

Browse files
authored
fix: export sortgroup functions
1 parent f97f1ac commit cf4e11b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pkg/sortgroup/sortgroup.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
// groups elements of the slice into a map based on a key function
10-
func groupBy[T any, K comparable](slice []T, keyFunc func(T) K) map[K][]T {
10+
func GroupBy[T any, K comparable](slice []T, keyFunc func(T) K) map[K][]T {
1111
result := make(map[K][]T)
1212
for _, v := range slice {
1313
key := keyFunc(v)
@@ -17,7 +17,7 @@ func groupBy[T any, K comparable](slice []T, keyFunc func(T) K) map[K][]T {
1717
}
1818

1919
// generic sort
20-
func sortSlice[T constraints.Ordered](slice []T) {
20+
func SortSlice[T constraints.Ordered](slice []T) {
2121
sort.Slice(slice, func(i, j int) bool {
2222
return slice[i] < slice[j]
2323
})

pkg/sortgroup/sortgroup_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestGroupBy(t *testing.T) {
3636

3737
for _, tt := range tests {
3838
t.Run(tt.name, func(t *testing.T) {
39-
if got := groupBy(tt.slice, tt.keyFunc); !reflect.DeepEqual(got, tt.want) {
39+
if got := GroupBy(tt.slice, tt.keyFunc); !reflect.DeepEqual(got, tt.want) {
4040
t.Errorf("groupBy() = %v, want %v", got, tt.want)
4141
}
4242
})
@@ -56,7 +56,7 @@ func TestSortSlice(t *testing.T) {
5656

5757
for _, tt := range tests {
5858
t.Run(tt.name, func(t *testing.T) {
59-
sortSlice(tt.slice) // Modify the slice in-place
59+
SortSlice(tt.slice) // Modify the slice in-place
6060
if !reflect.DeepEqual(tt.slice, tt.want) {
6161
t.Errorf("sortSlice() resulted in %v, want %v", tt.slice, tt.want)
6262
}

0 commit comments

Comments
 (0)