What is the equation for sortrows

Hi,
I was wondering what the equivalent equation for (sortrows) in Matlab. Let's say:
B = sortrows(A,2)
If there is an idea, I really appreciate because I just want to understand the concept mathematically

댓글 수: 2

You mean what the specific algorithm is that Mathworks used to implement this? They will probably not tell you.
And there is a difference between algorithm and equation.
What sortrows is doing (or something equivalent) is this:
function B=equivalent_to_sortrows(A,col)
[~,sort_order]=sort(A(:,col));
B=A(sort_order,:);
end
So the meat of the algorithm is just a sort.
Please post your comment as a comment, and not in the answer field. Their order can change, which makes reading the thread very confusing later on.
As far as I know there is not an equation that describes a sort algorithm, other than the trivial solution:
B=f(A,c)
where f sorts A according to column c
which would be a valid mathematical description, but would tell you anything.

댓글을 달려면 로그인하십시오.

답변 (1개)

Isaac Adam
Isaac Adam 2018년 8월 20일

0 개 추천

Thanks a lot for the reply. Yes, I'm looking for a simple equation let's say I have a matrix of point A and I create a new matrix called B, then the sorting
B = sortrows(A,2);
so the row sorting is done s based on the second column. Is there any way to express this in equation format.

카테고리

도움말 센터File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

질문:

2018년 8월 20일

댓글:

Rik
2018년 8월 20일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by