Skip to content

Sorting

These pipes are used to sort the given value.

Note

These pipes are only applicable on array or string inputs

Sort Ascending

This value pipe orders the given value in ascending order.

1
2
3
4
5
const value = ['b', 'x', 'a', 'm'];

const pipe = getValuePipe('sort-ascending');

console.log(pipe(value))

Output

[ 'a', 'b', 'm', 'x' ]
1
2
3
4
5
6
7
8
const generator = getValueGenerator('constant-value', {
    value: ['b', 'x', 'a', 'm'],
    pipes: [
        'sort-ascending'
    ]
});

console.log(generator.generate())

Output

[ 'a', 'b', 'm', 'x' ]

Tip

This example uses Constant Value Generator. You may want to check it out 😉

Sort Descending

This value pipe orders the given value in descending order.

1
2
3
4
5
const value = ['b', 'x', 'a', 'm'];

const pipe = getValuePipe('sort-descending');

console.log(pipe(value))

Output

[ 'x', 'm', 'b', 'a' ]
1
2
3
4
5
6
7
8
const generator = getValueGenerator('constant-value', {
    value: ['b', 'x', 'a', 'm'],
    pipes: [
        'sort-descending'
    ]
});

console.log(generator.generate())

Output

[ 'x', 'm', 'b', 'a' ]

Tip

This example uses Constant Value Generator. You may want to check it out 😉