sort

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

README

String sort

func ExampleQuick3() {
	data := []string{
		"ABABC",
		"ABAAA",
		"BBAAA",
		"CA",
		"HUAWEI",
		"AA",
		"张豪",
		"张三",
		"李四",
		"王麻子",
		"李二狗",
	}
	// HighPrior(data)
	Quick3(data)
	fmt.Println(data)
	// Output: [AA ABAAA ABABC BBAAA CA HUAWEI 张三 张豪 李二狗 李四 王麻子]
}

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func HighPrior

func HighPrior(strings []string)
Example
data := []string{
	"ABABC",
	"ABAAA",
	"BBAAA",
	"CA",
	"HUAWEI",
	"AA",
	"张豪",
	"张三",
	"李四",
	"王麻子",
	"李二狗",
}
HighPrior(data)
fmt.Println(data)
Output:

[AA ABAAA ABABC BBAAA CA HUAWEI 张三 张豪 李二狗 李四 王麻子]

func HighPriorAlp

func HighPriorAlp(a alphabet.IAlp, data []string)

HighPriorAlp sort strings with a user-defined alphabet

func Quick3

func Quick3(strings []string)

Quick3 seems to be a faster string sorting algorithm than the sort.Strings method in the standard library

Example
data := []string{
	"ABABC",
	"ABAAA",
	"BBAAA",
	"CA",
	"HUAWEI",
	"AA",
	"张豪",
	"张三",
	"李四",
	"王麻子",
	"李二狗",
}
Quick3(data)
fmt.Println(data)
Output:

[AA ABAAA ABABC BBAAA CA HUAWEI 张三 张豪 李二狗 李四 王麻子]

func Quick3Alp

func Quick3Alp(a alphabet.IAlp, data []string)

Types

This section is empty.

Jump to

Keyboard shortcuts

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