diff --git a/pkg/printers/internalversion/describe.go b/pkg/printers/internalversion/describe.go index e334cf6dd35..68144788aae 100644 --- a/pkg/printers/internalversion/describe.go +++ b/pkg/printers/internalversion/describe.go @@ -3808,23 +3808,19 @@ func printTaintsMultilineWithIndent(w PrefixWriter, initialIndent, title, innerI } // to print taints in the sorted order - keys := make([]string, 0, len(taints)) - for _, taint := range taints { - keys = append(keys, string(taint.Effect)+","+taint.Key) - } - sort.Strings(keys) - - for i, key := range keys { - for _, taint := range taints { - if string(taint.Effect)+","+taint.Key == key { - if i != 0 { - w.Write(LEVEL_0, "%s", initialIndent) - w.Write(LEVEL_0, "%s", innerIndent) - } - w.Write(LEVEL_0, "%s\n", taint.ToString()) - i++ - } + sort.Slice(taints, func(i, j int) bool { + cmpKey := func(taint api.Taint) string { + return string(taint.Effect) + "," + taint.Key } + return cmpKey(taints[i]) < cmpKey(taints[j]) + }) + + for i, taint := range taints { + if i != 0 { + w.Write(LEVEL_0, "%s", initialIndent) + w.Write(LEVEL_0, "%s", innerIndent) + } + w.Write(LEVEL_0, "%s\n", taint.ToString()) } }