Ninjas Practicing Multidimensionality

## fort

0.1.0 • Public • Published

# fort

Sort, min, and max by a transform function.

# example

## minimum of some rows

``````{ x: 2 }
``````

## ascending rows

``````[ { x: 2 }, { x: 3 }, { x: 5 }, { x: 9 } ]
``````

## ascending modulo sort

``````[ 4, 8, 1, 2, 6, 2, 3, 7 ]
``````

# methods

## fort.min(xs, f)

Return the minimum value from the elements in `xs` after transforming by `f(x)` on each element `x` in `xs`.

The return value will be from the original elements in `xs`, not the transformed set.

## fort.max(xs, f)

Return the minimum value from the elements in `xs` after transforming by `f(x)` on each element `x` in `xs`.

The return value will be from the original elements in `xs`, not the transformed set.

## fort.ascend(xs, f)

Return the elements from `xs` sorted into ascending order after transforming by `f(x)` on each `x` element in `xs`.

The return array will be comprised of the original elements from `xs`, not the transformed values from `f(x)`.

If `xs` is a function or undefined, return a comparison function using `xs` or the identity as the function transform.

## fort.descend(xs, f)

Return the elements from `xs` sorted into descending order after transforming by `f(x)` on each `x` element in `xs`.

The return array will be comprised of the original elements from `xs`, not the transformed values from `f(x)`.

If `xs` is a function or undefined, return a comparison function using `xs` or the identity as the function transform.

## fort.rise(xs, f)

Alias for `fort.ascend()` that is more consistent with the fort theme of this module.

## fort.fall(xs, f)

Alias for `fort.descend()` that is more consistent with the fort theme of this module.

# install

With npm do:

``````npm install fort
``````

MIT

## Keywords

none

### install

`npm i fort`

9

0.1.0

none

github