...

Package sort

Overview ▾

Provides an implementation for merge sort sorting algorithm

func MergeSort

func MergeSort(array []float64) []float64

MergeSort receives a slice and returns a new sorted slice

func NaturalCompare

func NaturalCompare(a, b string) bool

NaturalCompare returns true if the first string precedes the second one according to natural order

func NaturalSort

func NaturalSort(l []string)

NaturalSort performs natural sorting on a slice of strings. Natural sorting orders strings in a way that respects numeric values within the strings. For example: ["file1.txt", "file10.txt", "file2.txt"] will be sorted as ["file1.txt", "file2.txt", "file10.txt"] instead of the standard lexicographical sort. Note: This sorting is case sensitive. For example: ["a1", "A2", "b1", "B2"] will be sorted as ["A2", "B2", "a1", "b1"] because uppercase letters come before lowercase in ASCII.