Skip to content

Commit f5007d8

Browse files
committed
Sort results
1 parent f2fa34e commit f5007d8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

main.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"log"
99
"os"
10+
"sort"
1011
"strconv"
1112
"strings"
1213
"syscall"
@@ -202,16 +203,16 @@ func (f *File) getContent(ctx context.Context) (string, error) {
202203
items = append(items, output.Items...)
203204
}
204205

206+
sort.Slice(items, func(i, j int) bool {
207+
return items[i]["timestamp"].(*types.AttributeValueMemberN).Value < items[j]["timestamp"].(*types.AttributeValueMemberN).Value
208+
})
209+
205210
var lines []string
206211
for _, item := range items {
207212
line := item["content"].(*types.AttributeValueMemberS).Value
208213
lines = append(lines, line)
209214
}
210215

211-
for i, j := 0, len(lines)-1; i < j; i, j = i+1, j-1 {
212-
lines[i], lines[j] = lines[j], lines[i]
213-
}
214-
215216
content := strings.Join(lines, "\n") + "\n"
216217

217218
// The initial cache should be stored on the machine as a file, that

0 commit comments

Comments
 (0)