Smartsort - A smart sorting algorithm for Go to sort filename containing digits that is not zero padded

smartsort

A smart sorting algorithm for Go to sort filename containing digits that is not zero padded

Usage

import "github.com/tobychui/smartsort/sorter"
sortedSlice := sorter.SortString(stringSlice)

Examples

original := []string{"a1c.o", "A1c.o", "a2016c.o", "a10c.o", "a2c.o", "A2c.o", "a11c.o"}
fmt.Println("Before: ", original)
results := sorter.SortString(original)
fmt.Println("After: ", results)

Outputs

Before:  [a1c.o A1c.o a2016c.o a10c.o a2c.o A2c.o a11c.o]
After:  [A1c.o A2c.o a1c.o a2c.o a10c.o a11c.o a2016c.o]

Notes

This is a space-time tradeoff version (this use more memory) of the algorithm used by natsort. Take a look at natsort if you have many CPU resources but no memory: https://github.com/facette/natsort

Owner
Toby Chui
Both Software and Hardware developer, focus in Cloud Desktop Environment, Web 3D, IoT and open source projects (`・ω・´)
Toby Chui
Similar Resources

Zero allocation Nullable structures in one library with handy conversion functions, marshallers and unmarshallers

nan - No Allocations Nevermore Package nan - Zero allocation Nullable structures in one library with handy conversion functions, marshallers and unmar

Dec 20, 2022

Type-safe, zero-allocation sets for Go

Set Package set is a type-safe, zero-allocation port of the excellent package fatih/set. It contains sets for most of the basic types and you can gene

Jan 5, 2023

dagger is a fast, concurrency safe, mutable, in-memory directed graph library with zero dependencies

dagger is a fast, concurrency safe, mutable, in-memory directed graph library with zero dependencies

dagger is a blazing fast, concurrency safe, mutable, in-memory directed graph implementation with zero dependencies

Dec 19, 2022

Data structure and algorithm library for go, designed to provide functions similar to C++ STL

GoSTL English | 简体中文 Introduction GoSTL is a data structure and algorithm library for go, designed to provide functions similar to C++ STL, but more p

Dec 26, 2022

Multi-String Pattern Matching Algorithm Using TrieHashNode

Multi-String Pattern Matching algorithm. This implementation is inspired from Aho-Corasick algorithm Getting Started modelA = mspm.NewModel("mspm_mode

Dec 9, 2022

A Go implementation of the 64-bit xxHash algorithm (XXH64)

xxhash xxhash is a Go implementation of the 64-bit xxHash algorithm, XXH64. This is a high-quality hashing algorithm that is much faster than anything

Dec 22, 2022

Implementation of Boyer-Moore fast string search algorithm in Go

boyermoore Implementation of Boyer-Moore fast string search algorithm in Go

Oct 7, 2022

A Go implementation of the core algorithm in paper Indexing Boolean Expression

Boolean Expression Indexer Go library A Go implementation of the core algorithm in paper Indexing Boolean Expression, which already supports the fol

Dec 26, 2022

记录算法学习和LeetCode、LintCode、codewars的学习路程。A record of algorithm learning.

Problem List Leetcode、LintCode、Codewars Algorithm problem solution written by golang. LeetCode id Name(Github) Name(Gitee) 00001 TwoSum TwoSum 00003 L

Nov 3, 2021
The simplest sorting algorithm that sorts in quadratic time
The simplest sorting algorithm that sorts in quadratic time

Simplest sort Showcases the simplest sorting algorithm that works in quadratic time. From here. The pseudocode for this algo can be seen below (sorts

Oct 14, 2022
May 15, 2022
A radix sorting library for Go (golang)

zermelo A radix sorting library for Go. Trade memory for speed! import "github.com/shawnsmithdev/zermelo" func foo(large []uint64) zermelo.Sort(l

Jul 30, 2022
Distributed merge sort for large sets across nodes in a network

distMergeSort An implementation of mergesort distributed across nodes used to sort large sets. Introduction Merge sort partitions sets so that they ca

Jul 8, 2022
Stalin sort in multiple languages!

stalin-sort Stalin sort in multiple languages, contributions are welcome! Motivation This repo is motivated by this tweet, this tweet contains a refer

Jan 14, 2022
Code in this repository solves the game Water Sort Puzzle for phones
Code in this repository solves the game Water Sort Puzzle for phones

Water Sort Puzzle Solver This code can solve a game called "Water Sort Puzzle" available on APPStore and PlayMarket. Start Guide Firstly, you have to

Nov 5, 2022
Implementation of external merge sort with 2-way merge.

External merge sort An implementation of external merge sort algorithm (with 2-way merge) written in Go. This particular implementation sorts strings.

Jan 16, 2022
Collections for Golang using generics. Currently containing Hash Set.
Collections for Golang using generics. Currently containing Hash Set.

Implementation of missing colections for Golang using Generics. Free of dependencies. Curently in early development phase. Requirements Go 1.18+ Insta

Dec 30, 2021
Brushing questions is not the goal, but the mastering method is

Brushing questions is not the goal, but the mastering method is If you think it

Jan 8, 2022