inmemory

package
v0.0.1-rc20230124 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package inmemory provides sorting algorithms for in-memory data.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func SortSlice

func SortSlice(input []string)

SortSlice sorts the given slice of strings ascendant. The given input will be modified after its call. To sort a slice of strings descendant, use SortSliceFunc.

Example
package main

import (
	"fmt"

	"github.com/Code-Hex/dd"
	"github.com/KEINOS/go-sortfile/sortfile/inmemory"
)

func main() {
	lines := []string{
		"foo",
		"bar",
		"baz",
	}

	// Sort slices of strings.
	// For benchmark between other algorithms, see the benchmark_test.go.
	inmemory.SortSlice(lines)

	fmt.Println(dd.Dump(lines))
}
Output:

[]string{
  "bar",
  "baz",
  "foo",
}

func SortSliceFunc

func SortSliceFunc(input []string, less func(a, b string) bool)

SortSliceFunc is similar to SortSlice but it takes a function to compare two strings. The given input will be modified after its call.

Types

This section is empty.

Jump to

Keyboard shortcuts

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