sorts

package
v0.0.0-...-fc75448 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 License: MIT Imports: 0 Imported by: 0

README

sorts

  • sort_struct.go

对自定义类型进行排序的解决方法 可以对自定义的Persons 按Name或者Age或者Height 纬度进行排序;

type Person struct {
	Name   string
	Age    int
	Height int
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Person

type Person struct {
	Name   string
	Age    int
	Height int
}

type Persons

type Persons []Person

func (Persons) Len

func (p Persons) Len() int

func (Persons) Swap

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

type SortByAge

type SortByAge struct{ Persons }

func (SortByAge) Less

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

降序

type SortByHeight

type SortByHeight struct{ Persons }

func (SortByHeight) Less

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

降序

type SortByName

type SortByName struct{ Persons }

继承 Person 的所有属性和方法

func (SortByName) Less

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

降序

Jump to

Keyboard shortcuts

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