ExampleToSliceOrdered demonstrates sorting different ordered types
()
| 193 | |
| 194 | // ExampleToSliceOrdered demonstrates sorting different ordered types |
| 195 | func 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 |
| 213 | func ExampleSet_ToSlice() { |
nothing calls this directly
no test coverage detected