Get Help

Turn on suggestions

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

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Re: Csort, is it true?

Options

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

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

Showing results for

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

12-31-2010
07:56 AM

12-31-2010
07:56 AM

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

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

12-31-2010
08:25 AM

12-31-2010
08:25 AM

25 REPLIES 25

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

12-31-2010
08:25 AM

12-31-2010
08:25 AM

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

12-31-2010
08:29 AM

12-31-2010
08:29 AM

Re: Csort, is it true?

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

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

12-31-2010
10:00 AM

12-31-2010
10:00 AM

Re: Csort, is it true?

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.

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

12-31-2010
10:57 AM

12-31-2010
10:57 AM

Re: Csort, is it true?

And what about rsort?

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

12-31-2010
11:50 AM

12-31-2010
11:50 AM

Re: Csort, is it true?

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

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

01-02-2011
11:50 AM

01-02-2011
11:50 AM

Re: Csort, is it true?

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

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

01-11-2021
05:20 PM

01-11-2021
05:20 PM

Re: Csort, is it true?

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

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

01-11-2021
05:34 PM

01-11-2021
05:34 PM

Re: Csort, is it true?

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

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

12-31-2010
07:35 PM

12-31-2010
07:35 PM

Re: Csort, is it true?

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

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

01-01-2011
08:54 AM

01-01-2011
08:54 AM

Re: Csort, is it true?

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.

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

01-01-2011
02:30 AM

01-01-2011
02:30 AM

Re: Csort, is it true?

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

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

01-01-2011
03:29 AM

01-01-2011
03:29 AM

Re: Csort, is it true?

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

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

01-01-2011
08:57 AM

01-01-2011
08:57 AM

Re: Csort, is it true?

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

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

01-02-2011
11:55 AM

01-02-2011
11:55 AM

Re: Csort, is it true?

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

Mike

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

01-02-2011
03:40 PM

01-02-2011
03:40 PM

Re: Csort, is it true?

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

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

01-02-2011
06:07 PM

01-02-2011
06:07 PM

Re: Csort, is it true?

Has that always been the case with Mathcad?

I take it Mathcad treats the letters as numbers?

Mike

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

01-02-2011
06:20 PM

01-02-2011
06:20 PM

Re: Csort, is it true?

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

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

01-03-2011
05:04 AM

01-03-2011
05:04 AM

Re: Csort, is it true?

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

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

01-03-2011
09:53 AM

01-03-2011
09:53 AM

Re: Csort, is it true?

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

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

01-03-2011
10:40 AM

01-03-2011
10:40 AM

Re: Csort, is it true?

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!

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

01-03-2011
11:51 AM

01-03-2011
11:51 AM

Re: Invisible variable/function/operator name

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.

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

01-03-2011
12:39 PM

01-03-2011
12:39 PM

Re: Invisible variable/function/operator name

Example 5. Invisible matker on the plot:

Example 6. Duoble answer with two units:

Example 7. Endless loop:

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

01-03-2011
10:47 AM

01-03-2011
10:47 AM

Re: Csort, is it true?

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

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

01-04-2011
02:43 AM

01-04-2011
02:43 AM

Re: Csort, is it true?

Now that has no logic at all.

Mike

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

01-04-2011
02:41 AM

01-04-2011
02:41 AM

Re: Csort, is it true?

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

Complained!!!!!!!!

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

Mike