Sorting football teams

Report a typo

Below you will see an unordered table of the top 4 Bundesliga Football ⚽ teams from Season 2020-21:

Team Points
Borussia Dortmund 64
Bayern Munich 78
RB Leipzig 65
VfL Wolfsburg 61

We've already created the teams slice of the Team type for you. Please implement a sorting operation on the teams slice with the sort.Slice() function that properly sorts the teams from highest to lowest points only!

Write a program in Go
package main

import (
"fmt"
"sort"
)

type Team struct {
Name string
Points int
}

func main() {
teams := []Team{
{"Borussia Dortmund", 64},
{"Bayern Munich", 78},
{"RB Leipzig", 65},
{"Vfl Wolfsburg", 61},
}

// Implement the logic within the sort.Slice() function below to sort the teams slice!
sort.Slice(teams, func(i, j int) bool {
return ?
})

// Do not delete the output line!
fmt.Println(teams)
}
___

Create a free account to access the full topic