Have you ever wanted a channel that partially sorts the values being passed through it? For example, you have some kind of work queue and you want to do the most important work first. Well, now you can!
github.com/twpayne/go-heap.PriorityChannel <https://pkg.go.dev/github.com/twpayne/go-heap#PriorityChannel> implements this: give it a channel and a comparison function and you get back a new channel that returns values in priority order until the original channel is closed. Only want the highest priority value from the last N? Then use github.com/twpayne/go-heap.BufferedPriorityChannel <https://pkg.go.dev/github.com/twpayne/go-heap#BufferedPriorityChannel>. Code is at https://github.com/twpayne/go-heap/blob/main/prioritychannel.go. It's a fun combination of generics, iterators, and channels. Feedback welcome! Regards, Tom -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/95ad14df-81aa-48c7-b3a3-658bd747f82cn%40googlegroups.com.