zsort

package
v0.0.0-...-473e0bf Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2019 License: GPL-3.0 Imports: 1 Imported by: 4

Documentation

Overview

对无序序列进行排序

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func BubbleSort

func BubbleSort(data sort.Interface)

BubbleSort 冒泡排序. data必须实现sort包中的Interface接口

Example
// declare a array
// this array must implenet sort.Inerface
data := sort.IntSlice{22, 34, 3, 40, 18, 4}
BubbleSort(data)
Output:

func DictSort

func DictSort(keys []string) []string

DictSort 字典排序

func QuickSort

func QuickSort(data sort.Interface)

QuickSort 快速排序, data必须要实现sort包的Interface接口

Example
// declare a array
// this array must implenet sort.Inerface
data := sort.IntSlice{22, 34, 3, 40, 18, 4}
QuickSort(data)
Output:

func SelectSort

func SelectSort(data sort.Interface)

SelectSort 选择排序, data必须实现sort包中的Interface接口

Example
// declare a array
// this array must implenet sort.Inerface
data := sort.IntSlice{22, 34, 3, 40, 18, 4}
SelectSort(data)
Output:

Types

type Pair

type Pair struct {
	Key   string
	Value int
}

type PairList

type PairList []Pair

func SortByValue

func SortByValue(valueMap map[string]int) PairList

SortByValue 按照map的value进行降序排列

func (PairList) Len

func (p PairList) Len() int

func (PairList) Less

func (p PairList) Less(i, j int) bool

func (PairList) Swap

func (p PairList) Swap(i, j int)

Jump to

Keyboard shortcuts

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