aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoop <Joop Kiefte>2022-04-02 05:56:34 +0100
committerjoop <Joop Kiefte>2022-04-02 05:56:34 +0100
commita92cdf9c89a0530f72d1744e132dfdc542fe4b46 (patch)
treea2b98dd693f071538efb66252fe99427e89f1790
parent5d5df5a089b16b56026d831136362baeb97637ec (diff)
Now sorting works
-rw-r--r--main.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/main.go b/main.go
index 10a72b1..1976f7f 100644
--- a/main.go
+++ b/main.go
@@ -333,7 +333,6 @@ func main() {
fmt.Println(prayer.Text)
fmt.Println("ID:", prayer.Id)
fmt.Println("Author:", prayer.Author())
- matchcode:
for code == "" {
// Ask for a keyword
fmt.Print("Input a keyword for this prayer, skip to pick another one or code to enter the code manually: ")
@@ -350,9 +349,9 @@ func main() {
// Check for the prayer text of each prayer in
// PrayersWithCode if there is a match with the keyword
// and add it to Matches
- for _, prayer := range PrayersWithCode {
- if strings.Contains(prayer.Text, keyword) {
- Matches = append(Matches, prayer)
+ for _, pr := range PrayersWithCode {
+ if strings.Contains(pr.Text, keyword) {
+ Matches = append(Matches, pr)
}
}
// If there are no matches, ask again
@@ -363,7 +362,9 @@ func main() {
// Ask which of the matches to use
fmt.Println("Found " + strconv.Itoa(len(Matches)) + " matches.")
fmt.Println("Which of the following matches?")
- for i, match := range Matches {
+ sortedMatches := NewPrayerLengthSort(Matches, prayer)
+ sortedMatches.Sort()
+ for i, match := range sortedMatches.Prayers() {
fmt.Println(i+1, ":", match.Text)
fmt.Print("Does this match? (y/n/skip) ")
answer := prompt.MustRead[string]()
@@ -373,7 +374,7 @@ func main() {
break
}
if answer == "skip" {
- break matchcode
+ break
}
}
}