The top lane champions

Report a typo

Dyrus has created a slice with his favorite old-school League of Legends champions. However, he wants to sort it based on the length of each name of the champion — the shortest name first and the longest name last!

Please help him implement the sorting function required for this task. To do this, you will need to use the sort.Slice() function along with the builtin function len on the names of each champion!

Write a program in Go
package main

import (
"fmt"
"sort"
)

func main() {
champions := []string{"Jax", "Mordekaiser", "Singed", "Rumble", "Irelia"}

// Write the required logic below to sort the 'champions' slice based on
// the shortest name to longest name!
sort.Slice(?, func(i, j int) bool {
return len(?) ? len(?)
})

fmt.Println(champions)
}
___

Create a free account to access the full topic