Skip to content

Glossary: Data Structures and Algorithms in Go

Comparison function

Also written: comparison functions

A function that takes two items and returns a negative number if the first goes first, a positive number if the second goes first and 0 for a tie. You pass it to `slices.SortFunc` to sort structs by any field.

Where the book teaches it

Related terms

Function literalslices.SortFuncStable sort