From cf136772fe7bb13943db704be0c22e2975beb134 Mon Sep 17 00:00:00 2001 From: Sebastian Frank Date: Mon, 1 Jul 2024 15:05:36 +0200 Subject: [PATCH] feat: improve sorting functionality in collectionGetHandler The code changes in `handler.go` modify the `collectionGetHandler` function in the API handler. The changes introduce a more robust sorting functionality by splitting the sort parameter by comma and appending each part to the `clearedSort` slice. This allows for multiple sort criteria to be applied. --- handler.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/handler.go b/handler.go index acc12b8..6ef928e 100644 --- a/handler.go +++ b/handler.go @@ -136,8 +136,11 @@ func (api *API) collectionGetHandler(m mgocrud.ModelInterface) gin.HandlerFunc { } clearedSort := []string{} for _, s := range sort { - if s != "" { - clearedSort = append(clearedSort, s) + // split by comma and append all parts to clearedSort + for _, sPart := range strings.Split(s, ",") { + if sPart != "" { + clearedSort = append(clearedSort, sPart) + } } }