Skip to content

SORT_VECTOR

The SORT_VECTOR node returns the input Vector that is sorted Inputs ------ default : Vector The input vector Params: reverse : bool If False, sort in ascending order. If True, descending order. Returns: out : Vector Sorted input vector
Python Code
from flojoy import flojoy, Vector


@flojoy
def SORT_VECTOR(
    default: Vector,
    reverse: bool = False,
) -> Vector:
    """The SORT_VECTOR node returns the input Vector that is sorted

    Inputs
    ------
    default : Vector
        The input vector

    Parameters
    ----------
    reverse : bool
        If False, sort in ascending order. If True, descending order.

    Returns
    -------
    Vector
        Sorted input vector
    """
    return Vector(v=sorted(default.v, reverse=reverse))

Find this Flojoy Block on GitHub

Example

Having problems with this example app? Join our Discord community and we will help you out!
React Flow mini map

In this example, we create a Vector type data that is in descending order using LINSPACE.

Using SORT_VECTOR node, we sort the Vector type data in ascending order.