jisx4061

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2022 License: MIT Imports: 2 Imported by: 0

README

jisx4061

Package jisx4061 implements JIS X 4061 Japanese character string collation order. It is commonly referred to as "辞書順(the dictionary order)", "50音順(the syllabic order), "あいうえお順(the a-i-u-e-o order)".

SYNOPSIS

	list := []string{
		"さどう",
		"さとうや",
		"サトー",
		"さと",
		"さど",
		"さとう",
		"さとおや",
	}
	jisx4061.Sort(list)
	for _, s := range list {
		fmt.Println(s)
	}
	// Output:
	// さと
	// さど
	// さとう
	// さどう
	// さとうや
	// サトー
	// さとおや

REFERENCES

Documentation

Overview

Package jisx4061 implements JIS X 4061 Japanese character string collation order. It is commonly referred to as "辞書順(the dictionary order)", "50音順(the syllabic order), "あいうえお順(the a-i-u-e-o order)".

The collation method is simple collation (単純照合), where comparisons are made according to basic collation rules (基本照合規則). The Latin alphabet is processed, including macronised (マクロン付き文字) and circumflexed characters (サーカムフレックス付き文字). The extended Kanji character class (拡張漢字クラス) is used for the Kanji character class.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(a, b string) int

Less compares the strings a and b according to JIS X 4061. if a < b it returns -1, if a > b it returns 1, and if a == b it returns 0.

func IsSorted

func IsSorted(data []string) bool

IsSorted reports whether data is sorted.

func Less

func Less(a, b string) bool

Less compares the strings a and b according to JIS X 4061 and returns the result a < b.

func Sort

func Sort(s []string)

Sort sorts s.

Example
package main

import (
	"fmt"

	"github.com/shogo82148/jisx4061"
)

func main() {
	list := []string{
		"さどう",
		"さとうや",
		"サトー",
		"さと",
		"さど",
		"さとう",
		"さとおや",
	}
	jisx4061.Sort(list)
	for _, s := range list {
		fmt.Println(s)
	}
}
Output:

さと
さど
さとう
さどう
さとうや
サトー
さとおや

func Stable

func Stable(s []string)

Stable sorts s.

Types

type StringSlice

type StringSlice []string

StringSlice implements sort.Interface.

func (StringSlice) Len

func (s StringSlice) Len() int

Len implements sort.Interface.

func (StringSlice) Less

func (s StringSlice) Less(i, j int) bool

Less implements sort.Interface.

func (StringSlice) Swap

func (s StringSlice) Swap(i, j int)

Swap implements sort.Interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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