Lightweight wrapper to declare that a vector is sorted.
5 Stars
Updated Last
2 Years Ago
Started In
November 2018


Lifecycle Build Status

A very lightweight Julia package to declare that a vector is sorted.


Type ] to enter pkg mode, and install with

pkg> add SortedVectors

How to use

Standard constructor

The only exported symbol is SortedVector. Use

SortedVector([lt=isless], xs)

to sort xs and save the result in a vector. xs can be any <: AbstractVector. For immutable types (eg StaticArrays.SVector or UnitRange), setindex! will not work.

Special constructors for checking or skipping sorting

If your code emits sorted vectors, use the

SortedVector(SortedVectors.AssumeSorted(), lt, sorted_contents)

constructor. This will skip checks.

If your API accepts sorted vectors, and you want to check them, use the

SortedVector(SortedVectors.CheckSorted(), lt, sorted_contents)


In either case, you are responsible for ensuring that the argument vector is not modified later on. copy if you are unsure.

Supported interfaces


setindex! verifies that sorting is maintained.

Used By Packages

No packages found.