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

Function ExampleToSliceOrdered

pkg/set/example_test.go:195–210  ·  view source on GitHub ↗

ExampleToSliceOrdered demonstrates sorting different ordered types

()

Source from the content-addressed store, hash-verified

193
194// ExampleToSliceOrdered demonstrates sorting different ordered types
195func ExampleToSliceOrdered() {
196 // Works with any ordered type (int, float, string, etc.)
197 ints := set.Create(5, 2, 8, 1, 9)
198 fmt.Println("Sorted ints:", set.ToSliceOrdered(ints))
199
200 strings := set.Create("zebra", "apple", "mango", "banana")
201 fmt.Println("Sorted strings:", set.ToSliceOrdered(strings))
202
203 floats := set.Create(3.14, 2.71, 1.41, 1.73)
204 fmt.Println("Sorted floats:", set.ToSliceOrdered(floats))
205
206 // Output:
207 // Sorted ints: [1 2 5 8 9]
208 // Sorted strings: [apple banana mango zebra]
209 // Sorted floats: [1.41 1.73 2.71 3.14]
210}
211
212// ExampleSet_ToSlice demonstrates custom sorting with comparison function
213func ExampleSet_ToSlice() {

Callers

nothing calls this directly

Calls 2

CreateFunction · 0.92
ToSliceOrderedFunction · 0.92

Tested by

no test coverage detected