diff --git a/internal/dirtoexcel/dirtoexcel.go b/internal/dirtoexcel/dirtoexcel.go index 005a916..33bd9b5 100644 --- a/internal/dirtoexcel/dirtoexcel.go +++ b/internal/dirtoexcel/dirtoexcel.go @@ -5,7 +5,6 @@ import ( "math" "os" "regexp" - "sort" "strconv" "strings" "time" @@ -139,12 +138,9 @@ func Create(out, dir string) error { m[i.Company] += i.Value } - sm := SortMap(m) - valueLength := 0 - for k, v := range sm { - log.Info("KEY", "key", k, "category", cat) + for k, v := range m { if err := f.SetCellStr(cat, fmt.Sprintf("A%d", valueLength+1), k); err != nil { return fmt.Errorf("failed to set cell: %w", err) } @@ -224,21 +220,3 @@ func createCategoryChart(category string, length int, f *excelize.File) error { return nil } - -func SortMap[V any](m map[string]V) map[string]V { - r := map[string]V{} - - keys := make([]string, 0, len(m)) - - for key := range m { - keys = append(keys, key) - } - - sort.Strings(keys) - - for _, k := range keys { - r[k] = m[k] - } - - return r -} diff --git a/internal/dirtoexcel/dirtoexcel_test.go b/internal/dirtoexcel/dirtoexcel_test.go index 6b2ef4a..f33f748 100644 --- a/internal/dirtoexcel/dirtoexcel_test.go +++ b/internal/dirtoexcel/dirtoexcel_test.go @@ -124,27 +124,3 @@ func TestCategoriesInsert(t *testing.T) { is.Equal(dirtoexcel.Categories{"NonFood": []dirtoexcel.Value{{"AMAZON", 11.11}}}, m) } - -func TestSortMap(t *testing.T) { - tables := []struct { - name string - input map[string]int - expected map[string]int - }{ - { - "00", - map[string]int{"FOO": 1, "BAR": 2, "ZONK": 3}, - map[string]int{"BAR": 2, "FOO": 1, "ZONK": 3}, - }, - } - - is := is.New(t) - - for _, tt := range tables { - tt := tt - - t.Run(tt.name, func(t *testing.T) { - is.Equal(dirtoexcel.SortMap(tt.input), tt.expected) - }) - } -}