package main

import (
	"fmt"
	"maps"
	"slices"
)

func main() {
	// section: example
	m := map[string]int{
		"cherry": 3,
		"apple":  1,
		"banana": 2,
	}

	// slices.Sorted collects values from an iterator and returns
	// them as a sorted slice - combines Collect and Sort in one step
	sortedKeys := slices.Sorted(maps.Keys(m))
	fmt.Println("Sorted keys:", sortedKeys)

	// Compare with doing it manually:
	// keys := slices.Collect(maps.Keys(m))
	// slices.Sort(keys)

	// There's also SortedFunc for custom comparison
	// and SortedStableFunc for stable sorting with custom comparison
	// section: example
}
