Categorygithub.com/demouth/sortregular-go
repositorypackage
1.2.1
Repository: https://github.com/demouth/sortregular-go.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

SORT_REGULAR in Go

This repository contains a Go implementation of the SORT_REGULAR from PHP.

Usage

Import the package and use the sort_regular function:

package main

import (
	"github.com/demouth/sortregular-go"
)

func main() {
	strings := []string{
		"lemon",
		"apple",
		"0     ",
		" 1    ",
		"  2   ",
		"   3  ",
		"   04 ",
		"    05",
	}

	sortregular.SortRegular(strings)

	for _, s := range strings {
		println(s)
	}
}

PHP SORT_REGULAR

For reference, here's the original SORT_REGULAR in PHP:

<?php

$a = [
    'lemon',
    'apple',
    '0     ',
    ' 1    ',
    '  2   ',
    '   3  ',
    '   04 ',
    '    05',
];
sort($a);
var_dump($a);
/*
array(8) {
  [0]=>
  string(6) "0     "
  [1]=>
  string(6) " 1    "
  [2]=>
  string(6) "  2   "
  [3]=>
  string(6) "   3  "
  [4]=>
  string(6) "   04 "
  [5]=>
  string(6) "    05"
  [6]=>
  string(5) "apple"
  [7]=>
  string(5) "lemon"
}
*/