MCPcopy
hub / github.com/minio/minio-go / ExampleSet_ToSlice

Function ExampleSet_ToSlice

pkg/set/example_test.go:213–225  ·  view source on GitHub ↗

ExampleSet_ToSlice demonstrates custom sorting with comparison function

()

Source from the content-addressed store, hash-verified

211
212// ExampleSet_ToSlice demonstrates custom sorting with comparison function
213func ExampleSet_ToSlice() {
214 words := set.Create("go", "rust", "python", "javascript")
215
216 // Sort by length (shortest first)
217 byLength := words.ToSlice(func(a, b string) int {
218 return len(a) - len(b)
219 })
220
221 fmt.Println("By length:", byLength)
222
223 // Output:
224 // By length: [go rust python javascript]
225}
226
227// ExampleNew demonstrates creating an empty set and adding elements
228func ExampleNew() {

Callers

nothing calls this directly

Calls 2

CreateFunction · 0.92
ToSliceMethod · 0.45

Tested by

no test coverage detected