sortingAlgorithms: Sorting algorithms for vectors and lists

Description Usage Arguments Value

Description

These algorithms sort a list or vector by a given order relation (which defaults to <=). insertionSort is a stable O(n^2) sorting algorithm that is quite efficient for very small sets (less than around 20 elements). Use an O(n*log(n)) algorithm for larger sets.

Usage

1
insertionSort(xs, orderRelation = NULL)

Arguments

xs

The vector or list to sort.

orderRelation

The orderRelation to sort xs by (defaults to `<=`). This relation by should reflexive, antisymetric, and transitive.

Value

The vector or list xs sorted by the order relation orderRelation.


rgp documentation built on May 30, 2017, 12:45 a.m.