Skip to content

Commit

Permalink
feat(go): sort tasks by priority when printing
Browse files Browse the repository at this point in the history
  • Loading branch information
milanmlft committed Oct 22, 2024
1 parent 6045425 commit a4d2ee4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions todo-go/cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"log"
"sort"

"github.com/milanmlft/todo/todo-go/todo"
"github.com/spf13/cobra"
Expand All @@ -20,6 +21,8 @@ var listCmd = &cobra.Command{
if err != nil {
log.Fatalf("Failed to read todos from database with `%v`", err)
}
// Use Reverse to list higher priority first
sort.Sort(sort.Reverse(todos))
todos.Print()
},
}
Expand Down

0 comments on commit a4d2ee4

Please sign in to comment.