Skip to content

pvva/radixsort-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repository contains radix sort algorithm implementation in Go.

LSD sort is a bit tuned in terms of performance.

Numeric sort.

type MyType int64

func (t MyType) OrderN() int64 {
    return int64(t)
}

...

var list []radixsort.NumericOrder

radixsort.SortNumericOrder(list)
// 12, -8, 2, 4, 1, 5, -2, 7 => -8, -2, 1, 2, 4, 5, 7, 12

Lexicographical sort.

type MyType string

func (t MyType) OrderL() []byte {
    return []byte(t)
}

...

var list []radixsort.LexicographicalOrder

radixsort.SortLexicographicalOrder(list)
// "c", "a", "ba", "ab", "bb", "aaa" => "a", "aaa", "ab", "ba", "bb", "c"

Usage of, for example, insertion sort for lexicographical order for small lists is not done. It is actually not planned to be used for small arrays. Feel free to fork and adapt the code.

About

Radix sort implementation (both LSD and MSD)

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages