From 78f7aafb589d08fd5c79733d04870e9ed1953361 Mon Sep 17 00:00:00 2001 From: Theo-Hafsaoui Date: Sat, 9 Nov 2024 14:10:14 +0100 Subject: [PATCH] Add sorting --- internal/core/generate.go | 19 +++++++++++ internal/core/generate_test.go | 61 ++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/internal/core/generate.go b/internal/core/generate.go index dc00164..5c0a856 100644 --- a/internal/core/generate.go +++ b/internal/core/generate.go @@ -2,6 +2,8 @@ package core import ( "log/slog" + "sort" + "strings" ) type CVService struct{} @@ -32,3 +34,20 @@ func (g *CVService) GenerateTemplates(root string, source Source, templateReader } return nil } + +//Sorte a slice of items by the number of keyword +func sortByScore(items []string, keywords []string){ + sort.Slice(items, func(i, j int) bool { + return getScore(items[i],keywords)