Aller au contenu

# SORT_MATRIX

Ce contenu n’est pas encore disponible dans votre langue.

Take an input matrix and sort it along the chosen axis. Inputs ------ a : Matrix The input matrix to be multiplied to input b Params: axis : int Axis along which to sort. Default is -1, which means sort along the last axis. Returns: out : Matrix The matrix result from sorting.
Python Code
from numpy import sort
from flojoy import flojoy, Matrix

@flojoy
def SORT_MATRIX(a: Matrix, axis: int = -1) -> Matrix:
"""Take an input matrix and sort it along the chosen axis.

Inputs
------
a : Matrix
The input matrix to be multiplied to input b

Parameters
----------
axis : int
Axis along which to sort. Default is -1, which means sort along the last axis.

Returns
-------
Matrix
The matrix result from sorting.
"""
inputMatrix = a.m
sortedMatrix = sort(inputMatrix, axis=axis)

return Matrix(m=sortedMatrix)


Find this Flojoy Block on GitHub

## Example

In this example, we generate a Matrix type data using MATRIX node.
Using SORT_MATRIX, sort the matrix by the input axis.