magus v0.4.2 is out. See what's new
¶ View generated markdown
1 min read

sort

Ordering for string lists: lexicographic, natural (digit-aware), and semver.

Naming convention: import the module under its bare name (import "sort"), reach members with a backslash, and call methods in camelCase: sort\someMethod.

Methods

strings

Return a new list ordered lexicographically by byte. The plain alphabetical sort, and the one to reach for when the goal is a stable order rather than a meaningful one - a listing that must not change between runs.

Signature: sort\strings(items) -> []string - source

Parameter Type Optional Description
items []string

Returns: []string

natural

Return a new list ordered so embedded numbers compare as numbers: file2 before file10, where a lexicographic sort puts file10 first. Use it for anything a human will read - filenames, shard names, versioned directories - and note it is NOT a version sort; semver is.

Signature: sort\natural(items) -> []string - source

Parameter Type Optional Description
items []string

Returns: []string

semver

Return a new list ordered by semantic version, oldest first, so v1.9.0 precedes v1.10.0 and a prerelease precedes its release. Accepts tags with or without a leading v. Anything that is not a valid version sorts AFTER every valid one, in lexicographic order among themselves - so a stray tag is visible at the end rather than silently reordering the releases.

Signature: sort\semver(items) -> []string - source

Parameter Type Optional Description
items []string

Returns: []string

generatedreference/buzz/sortmodulestdlibmagusfile
Last updated (4f8cc295)
Earlier changes on this page (2)

Full history ↗ · Blame source ↗

Glossary

Magusfile

The magusfile.buzz that declares a project's targets (as export funs) and binds its spells. See targets.

Op

A single tool-native command a target composes (long form: operation); the middle of the work hierarchy (Spell to Op to Target). See operations.

Module

A magus stdlib namespace a magusfile imports for host capabilities: filesystem, exec, vcs, and more. See the module reference.

Buzz

The language magusfiles are written in (the .buzz engine). See engines.

Lease

One row of the lease ledger: a piece of work an orchestrating agent handed out, with its goal, the checkpoint it was cut against, and the paths it owns or must not touch. The ledger records; the agent guard is what reads those facts back when grading a write. See doctrine.

Conventions

This page uses none of the site's convention markers. The full set is on the conventions page.