Package 'versionsort'

Title: Sort and Order Version Codes
Description: A lightweight package for sorting version codes in various forms. No strong dependencies guaranteed.
Authors: Laura Bakala [cre, aut, cph]
Maintainer: Laura Bakala <[email protected]>
License: GPL (>= 3)
Version: 1.1.0
Built: 2024-11-20 05:35:24 UTC
Source: https://github.com/turtletopia/versionsort

Help Index


Find the latest version code

Description

ver_latest() returns the latest of the version codes.

Usage

ver_latest(x)

Arguments

x

character()
A vector of version codes that start with a number (as in "1.5.0"), i.e. without initial "v" (as in "v1.5.0").

Value

A character vector with one element.

See Also

ver_oldest()

Examples

ver_latest(c("1.3-0", "1.4-1", "0.0.0.9000", "1.4-0a", "1.4-0"))

Find the oldest version code

Description

ver_oldest() returns the oldest of the version codes.

Usage

ver_oldest(x)

Arguments

x

character()
A vector of version codes that start with a number (as in "1.5.0"), i.e. without initial "v" (as in "v1.5.0").

Value

A character vector with one element.

See Also

ver_latest()

Examples

ver_oldest(c("1.3-0", "1.4-1", "0.0.0.9000", "1.4-0a", "1.4-0"))

Order version codes

Description

ver_order() returns the permutation that rearranges a vector of version codes alphanumerically.

Usage

ver_order(x)

Arguments

x

character()
A vector of version codes that start with a number (as in "1.5.0"), i.e. without initial "v" (as in "v1.5.0").

Value

An integer vector (for details see order).

See Also

ver_sort()

Examples

version_codes <- c("1.5-0", "1.4-1", "0.0.0.9000", "1.4-0a", "1.4-0")
ver_order(version_codes)
# The line below is the same as ver_sort(version_codes)
version_codes[ver_order(version_codes)]

Sort version codes

Description

ver_sort() returns a sorted vector of version codes, where sorting is done alphanumerically.

Usage

ver_sort(x)

Arguments

x

character()
A vector of version codes that start with a number (as in "1.5.0"), i.e. without initial "v" (as in "v1.5.0").

Value

A character vector containing the same elements as input, but reordered.

See Also

ver_order()

Examples

ver_sort(c("1.5-0", "1.4-1", "0.0.0.9000", "1.4-0a", "1.4-0"))