79592499

Date: 2025-04-25 12:20:50
Score: 2.5
Natty:
Report link

How about using slices.Sort?

func (m Map) String() string {
    vs := []string{}
    for k, v := range m {
        vs = append(vs, fmt.Sprintf("%s:%s", k.String(), v.String()))
    }
    slices.Sort(vs)
    return fmt.Sprintf("{%s}", strings.Join(vs, ","))
}

Note for your Map that “If the key type is an interface type, [the comparison operators == and !=] must be defined for the dynamic key values; failure will cause a run-time panic.”

Reasons:
  • Probably link only (1):
  • Low length (0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Starts with a question (0.5): How
  • High reputation (-1):
Posted by: eik