package main

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

func main() {
	// section: example
	// slices.Collect collects values from an iterator into a slice
	m := map[string]int{
		"apple":  1,
		"banana": 2,
		"cherry": 3,
	}

	// Get all keys from a map as a slice using maps.Keys iterator
	keys := slices.Collect(maps.Keys(m))
	slices.Sort(keys) // Sort for consistent output
	fmt.Println("Keys:", keys)

	// Get all values from a map as a slice using maps.Values iterator
	values := slices.Collect(maps.Values(m))
	slices.Sort(values) // Sort for consistent output
	fmt.Println("Values:", values)
	// section: example
}
