magus v0.4.3 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 (0c2c811f)
Earlier changes on this page (3)

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.

Run

One target executing under one magus invocation, such as magus run test web or magus affected ci. A run keeps its captured output behind an output reference. Every magus run is a run whether or not any job asked for it; see Job for how the two relate.

Lease

The grant a holder takes on a job: the write and read paths that job declared, enforced in the checkout that took it with magus job exec. A job is the piece of work; a lease is permission over it.

Conventions

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