Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

** Community Tip** - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search.
X

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Dec 31, 2010
07:56 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Dec 31, 2010
07:56 AM

Csort, is it true?

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...

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

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

Dec 31, 2010
08:25 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

25 REPLIES 25

Dec 31, 2010
08:25 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Dec 31, 2010
08:25 AM

This seems to be a bug.

Mike

Dec 31, 2010
08:29 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Dec 31, 2010
08:29 AM

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?...

Dec 31, 2010
10:00 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Dec 31, 2010
10:00 AM

It is not a bug. When you sort by column 0 there are multiple solutions that are equally valid. The starting point is one valid solution, and the ending point is another. This may be considered undesirable behavior, but it's not a bug.

Tom wrote a Csort function that allows you to sort by multiple columns (csort does not preserve the order of previous sorts), but that also does not attempt to preserve the order of columns that are not specified for the sorting. So I modified it (in my opinion, the new version is an improvement over Tom's version, but then I wrote the modification, so I am biased ).

Edit: 11:50 AM Dec 31. I just uploaded a new file with a minor modificaton to the new function.

Dec 31, 2010
10:57 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Dec 31, 2010
10:57 AM

And what about rsort?

Dec 31, 2010
11:50 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Dec 31, 2010
11:50 AM

rsort behaves exactly the same as csort, except on the rows rather than the columns.

Jan 02, 2011
11:50 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jan 02, 2011
11:50 AM

It is not a bug. When you sort by column 0 there are multiple solutions that are equally valid. The starting point is one valid solution, and the ending point is another. This may be considered undesirable behavior, but it's not a bug.

Oh right, my mistake. Nice function by the way.

Maybe this should be added to the Prime request.

Mike

Jan 11, 2021
05:20 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jan 11, 2021
05:20 PM

A word of caution. The routine by Tom, as well as the improvement by Richard, fail if the matrix is large enough and you want to sort successively by enough columns. Demonstration:

Phew, it does.

But When I increase lc to 4 (add an extra column to the matrix):

The maximum difference is 8, not 0.

Row 8130 should follow, not precede rows 8131 and 8132.

QED

Luc

Jan 11, 2021
05:34 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jan 11, 2021
05:34 PM

Of course there's a solution. If you are willing to take a little more processing time you can get:

With 10 million matrix elements, no problem sorting on 10 columns.

The routine is recursive:

Success!

Luc

Dec 31, 2010
07:35 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Dec 31, 2010
07:35 PM

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

Jan 01, 2011
08:54 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jan 01, 2011
08:54 AM

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.

Jan 01, 2011
02:30 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jan 01, 2011
02:30 AM

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

Jan 01, 2011
03:29 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jan 01, 2011
03:29 AM

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

Jan 01, 2011
08:57 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jan 01, 2011
08:57 AM

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.".

Jan 02, 2011
11:55 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jan 02, 2011
11:55 AM

On another note - I was a little surprised to see that Mathcad can sort via text.

Mike

Jan 02, 2011
03:40 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jan 02, 2011
03:40 PM

I expect a lot of people would have complained if it couldn't!

Jan 02, 2011
06:07 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jan 02, 2011
06:07 PM

Has that always been the case with Mathcad?

I take it Mathcad treats the letters as numbers?

Mike

Jan 02, 2011
06:20 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jan 02, 2011
06:20 PM

As far as I can recall it has always worked with strings. The sort is alphabetic, so "a10" comes before "a2".

Jan 03, 2011
05:04 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jan 03, 2011
05:04 AM

I understand all about csort and Mathcad))) Thanks to all)))

In my opinion it will be good if developers will add alternate functions (alt_csort and alt_rsort). And those functions will work as I want! 😃 (yes, they will work slowly... but they will work!) Some tasks can't be solved with csort and rsort as they are today...

How do you think? Can we tell about this to developers? How can I do this? 😃

Jan 03, 2011
09:53 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jan 03, 2011
09:53 AM

Sergey Pichuzhkin wrote:

Can we tell about this to developers? How can I do this? 😃

The usual way is to write your message using invisible ink on black paper and seal it in a lead bottle floating it down your local river so that they can pick it up on the sea shores off Cambridge Mass. after it has gone around the Atlantic a few times

Well I think that has been the most effective method so far <big wink>

Philip

Jan 03, 2011
10:40 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jan 03, 2011
10:40 AM

Bearing in mind, of course, that nothing gets implemented until it has been suggested by at least ten people, ten times each, over a period of at least ten years, we should all get out our black paper and invisible ink and start writing!

Jan 03, 2011
11:51 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jan 03, 2011
11:51 AM

The usual way is to write your message using invisible ink...

I know 7 examples when the invisible variable/function/operator name is useful.

Do you know more?

Mathcad allow us to change the multiplication sign. A user may select the one from the following:

2×а 2·а 2 х a 2 а 2а

The multiplication sign is invisible in last two examples that conform to the tradition existing in mathematics do not place a sing between efficients, if the first is a constant and the second is a variable.

Comment

For that reason, a variable name cannot start with digits.

However, blank space between the two values may mean as addition, as multiplication. For example, 2 hours 30 minutes, 1 kilometer 200 metes etc. Here the invisible addition sign stands between the same quantities (time and length), and multiplication sign — between the constants and the units. Fig. 1 shows how to solve it in Mathcad.

Sometimes Mathcad is too pedantic in dimensional quantities. For example, one says that some equipment is situated at a height of twenty meters and another at zero and not specifies the units of that zero (meters, centimeters, feet, or inches etc). Nevertheless, Mathcad always displays the units of the dimensional values even when it is not necessary. In that case, we can hide an excess unit converting it to invisible (Fig. 2).

Mathcad works with decimal, binary, hexadecimal, octal numbers. However, we may need to make Mathcad work with forms more exotic, for example, with Roman numbers. For that, we insert the function with the invisible name that returns a Roman number if its argument is an Arabic and conversely the Arabic number if the argument is Roman (Fig. 3).

**Example 4. The sparse matrix**

Mathcad has powerful instruments to work with vectors and matrixes (arrays). There is one limitation: these arrays should be completely filled. In practice we sometimes deal with nonrectangular matrixes, for example, with triangular. The matrixes may have more complicated form. Fig. 4 shows how to imitate working with sparse matrix.

Jan 03, 2011
12:39 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jan 03, 2011
12:39 PM

Example 5. Invisible matker on the plot:

Example 6. Duoble answer with two units:

Example 7. Endless loop:

Jan 03, 2011
10:47 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jan 03, 2011
10:47 AM

Some tasks can't be solved with csort and rsort as they are today..

That is true. So unless you have a great deal of patience and are prepared to wait until the alternative functions are implemented (or the heat death of the universe occurs, which may be sooner), use the functions I posted

Jan 04, 2011
02:43 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jan 04, 2011
02:43 AM

Now that has no logic at all.

Mike

Jan 04, 2011
02:41 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jan 04, 2011
02:41 AM

I expect a lot of people would have complained if it couldn't!

Complained!!!!!!!!

WE DON'T COMPLANE ON HERE DO WE ??????

Mike