mapsort

package module
v0.0.0-...-0a48dbe Latest Latest
Warning

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

Go to latest
Published: May 6, 2015 License: MIT Imports: 1 Imported by: 2

README

mapsort

Golang utilities for sorting maps

Status

Ready to use

Programming notes

See abbreviation for a list of abbreviations used.

Documentation

Overview

Package mapsort provides functions for sorting maps.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyList

type KeyList []Pair

A slice of Pairs that implements sort.Interface to sort by Key.

func ByKey

func ByKey(myMap map[string]int, asc bool) KeyList

A function to turn a map into a KeyList, then sort and return it.

func (KeyList) Len

func (kl KeyList) Len() int

func (KeyList) Less

func (kl KeyList) Less(i, j int) bool

func (KeyList) Swap

func (kl KeyList) Swap(i, j int)

type Pair

type Pair struct {
	Key string
	Val int
}

A data structure to hold a key/value pair.

type ValList

type ValList []Pair

A slice of Pairs that implements sort.Interface to sort by Val.

func ByVal

func ByVal(myMap map[string]int, asc bool) ValList

A function to turn a map into a ValList, then sort and return it.

func (ValList) Len

func (vl ValList) Len() int

func (ValList) Less

func (vl ValList) Less(i, j int) bool

func (ValList) Swap

func (vl ValList) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL