You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
his function sorts input matrix A and corresponding matrices using sortrows. Output matrices are sorted such that the first output is a sorted version of A, and all other outputs are sorted in the same order as A. For example,
[B1,B2,...,Bn] = sortwith(A1,A2,...,An) is functionally equivalent to
[B1,ind] = sortrows(A1);
B2 = A2(ind);
.
.
.
Bn = An(ind);
Syntax
B = sortwith(A)
[B1,B2,...,Bn] = sortwith(A1,A2,...,An)
sortwith(...,'descend')
Description
B = sortwith(A) sorts the rows of A in ascending order. Argument A must be either a matrix or a column vector. This usage is exactly equivalent to B = sortrows(A).
[B1,B2,...,Bn] = sortwith(A1,A2,...,An) sorts matrices A1 through An corresponding to the order in which A1 is sorted.
sortwith(...,'descend') sorts the elements in descending order.
Cite As
Chad Greene (2026). sortwith (https://in.mathworks.com/matlabcentral/fileexchange/47515-sortwith), MATLAB Central File Exchange. Retrieved .
General Information
- Version 3.0.0.0 (8.79 KB)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
