Skip to main content
1-Visitor
December 31, 2010
Solved

Csort, is it true?

  • December 31, 2010
  • 3 replies
  • 14197 views

Hello!

Sorry for my english

I just found this "problem"

I think that first "mas" was sorted by first column. But "Mathcad 14" doesn't think so... And we get "mas1"... But again "Mathcad" doesn't think that "mas1" is sorted... and so on...

mathcad.jpg

This little thing brought me a lot of problems...

Can you tell me, is it error of "Mathcad 14"? Or it works as it should? And what should I do?..

Thank!

Sergey

Best answer by MikeArmstrong

This seems to be a bug.

Clipboard01.jpg

Mike

3 replies

1-Visitor
December 31, 2010

This seems to be a bug.

Clipboard01.jpg

Mike

1-Visitor
December 31, 2010

Thank, Mike! Happy new year!
I think that it is bug too... I try this function on Mathcad 14 M011, M035, Mathcad 15 - all works the same way...

But what should I do?...

1-Visitor
January 1, 2011

Thanks to all! Happy new year!

Okey, this may be considered as undesirable behavior (but it brought me many problems...(((( But in my opinion, it is not correctly.... Because csort will be do transforming of the same matrix many times. Yes, there are multiple solutions. But I think that there is only one highest priority solution, when you meet values in sorted matrix in the same order as in unsorted matrix, don't you think so?
I hope that developers will change this function and fix this "undesirable behavior". (this is not normal logic, when the function receives the correct answer, and gives back another correct answer)
Hope to see the response of developers.

Sergey

19-Tanzanite
January 1, 2011
Yes, there are multiple solutions. But I think that there is only one highest priority solution, when you meet values in sorted matrix in the same order as in unsorted matrix, don't you think so?

In an ideal world, yes. But that's not the way the algorithm used for csort works. The input vector could be checked to see if it is already sorted, but csort does not do that, presumably because of the extra overhead required. A small wrapper program could easily be written in Mathcad to do that though.

Hope to see the response of developers.

The developers never comment on these forums. As far as I know, they don't even read them.

24-Ruby IV
January 1, 2011

It seems that in the program of c(r)sort function we have not more operator but more or equal operator.

1-Visitor
January 1, 2011

I think so too (don't know enough algorithms, it seems like "bubble sort"...)

19-Tanzanite
January 1, 2011

I think so too (don't know enough algorithms, it seems like "bubble sort"...)

Bubble sort is a terrible algorithm. The csort function uses the heapsort algorithm (it says so in the help). You can read about it in chapter 8 here:

http://www.nrbook.com/a/bookcpdf.php

Note that the help also says: "The heapsort procedure is not a stable sort, meaning that if you sort values with repeated elements, they appear in an arbitrary order.".