cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

Multiple column sorting

terryhendicott
21-Topaz I

Multiple column sorting

Hi,

It is easy using the csort(M,n) command but it only operates on one column.

Is there an easy way to sort on first two columns.

Also need to add if first two columns are identical ?

Capture.JPG

Thanks

ACCEPTED SOLUTION

Accepted Solutions

I think there have been a couple of threads on this issue.  Tom Gutman, one of the old cadre, wrote one using rank sort.  Here's a thread in which @RichardJ  and @LucMeekes give solutions (Richard's was an improvement on Tom's, and Luc's is different - AFAICT, just scanning the message.  I haven't looked at the worksheets, but if they're by Tom, Richard, and Luc, the routines should be more than good enough for most purposes (Luc's handles larger matrices more reliably)

 

https://community.ptc.com/t5/Mathcad/Csort-is-it-true/m-p/706968/highlight/true#M193865 

 

By an interesting coincidence, I'm in the process of updating an old complex-number mergesort worksheet of mine to MP10.  I'm also fiddling around with it to see if I can get it to sort on functions ... no idea what the sorting criterion should be.

 

Stuart

View solution in original post

5 REPLIES 5

I think there have been a couple of threads on this issue.  Tom Gutman, one of the old cadre, wrote one using rank sort.  Here's a thread in which @RichardJ  and @LucMeekes give solutions (Richard's was an improvement on Tom's, and Luc's is different - AFAICT, just scanning the message.  I haven't looked at the worksheets, but if they're by Tom, Richard, and Luc, the routines should be more than good enough for most purposes (Luc's handles larger matrices more reliably)

 

https://community.ptc.com/t5/Mathcad/Csort-is-it-true/m-p/706968/highlight/true#M193865 

 

By an interesting coincidence, I'm in the process of updating an old complex-number mergesort worksheet of mine to MP10.  I'm also fiddling around with it to see if I can get it to sort on functions ... no idea what the sorting criterion should be.

 

Stuart

image.pngimage.pngimage.pngimage.png

Thank you @ttokoro this is excellent.

Cheers

Terry

x=0 and/or y=0 can treat. Bug fixed. Now P with 10,000 rows can treat by IJS(P) function.

image.png

image.png

Hi 

@ttokoro

It is being used for finite element analysis of large sparse matrices.  The first two columns are the matrix indices.  Last column is the value in the matrix.

Currently working on 46328x46328 matrix with 16,000,000 non zero elements.  Each element is typically visited four times meaning the start matrix is nearly 48,000,000 x 3 with the largest value in first and second columns of 46327.  The solver I have written in C++ using CUDA programming library cuDSS that is called by a Prime custom function.

 

Your file is very useful thank you.

Cheers

Terry

Announcements

Top Tags