sorts

package
v0.1.26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CmpBucketSort

func CmpBucketSort[K cmp.Ordered, V any](table map[K]V, fn func(value V) int) ([]K, error)

CmpBucketSort returns a sorted slice of keys from the given table, sorted by the value returned by the given function. The returned slice is sorted in ascending order of the sorting keys.

The function also supports duplicate keys. If two keys have the same sorting key, they will be sorted in the order they were added to the table.

Parameters:

  • table: a map from type to number of protections.
  • fn: a function that takes a value from the table and returns an integer that will be used as the sorting key.

Returns:

  • []K: a sorted slice of keys from the table.
  • error: an error if the function is nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳