cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP Security Notice: CVE-2026-109618 and CVE-2026-109619

    JMP promptly initiated a review of its products, services, and relevant infrastructure for exposure to CVE-2026-109618 and CVE-2026-109619.

    Our assessment of JMP products has not identified exposure to these vulnerabilities. Where remediation was required within supporting environments, appropriate security updates and controls have been applied and validated.

    We have identified no evidence of successful exploitation or unauthorized access to JMP systems or customer information associated with these vulnerabilities.

    JMP continues to monitor the issue and relevant vendor guidance. No action is required by JMP customers at this time.

  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.

JMP Wish List

We want to hear your ideas for improving JMP. Share them here.
Choose Language Hide Translation Bar
0 Kudos

Ability to sort a matrix and retain the indices

All, 
   When you have a matrix and you would like to sort the matrix, I am currently unaware of a function that would let me sort the matrix without using a loop over the columns or rows. I don't think this is particularly efficient. Additionally, there is no straight forward way to retain the positions once sorting is performed. Please see the following discussion for more details : 

https://community.jmp.com/t5/Discussions/Sort-a-matrix/m-p/85678#M38246 

 

   As you will see in the discussion , @Mark_Bailey was kind enough to offer a simple custom function, which I would think is useful to have in the JMP arsenal. 
   The function that @Mark_Bailey provided is shown below for convenince. 

 

A = [10 -12 4 8; 6 -9 8 0; 2 3 11 -2; 1 1 9 3];

sort matrix = Function( { m }, { t, b=[], i=[] },
 For( j = 1, j <= N Cols( m ), j++,
 t = A[0,j];
 b ||= Sort Descending( t );
 i ||= Matrix( Reverse( As List( Rank Index( t ) ) ) );
 );
 Eval List( { b, i } );
);

{ B, I } = sort matrix( A );

Show( A, B, I );

I also took the liberty of adding a little more along the same lines, so as to make it more generalized than my limited need :

 

sort matrix = Function( { m,order }, { t, b=[], i=[] },
							If(order == "ascending",
								For( r = 1, r <= N Cols( m ), r++,
									 t = A[0,r];
									 b ||= Sort Ascending( t );
									 i ||= Matrix( As List( Rank Index( t ) ) );
								   );
								Eval List( { b, i } );
								, 
								// else
								If(order == "descending",
									For( r = 1, r <= N Cols( m ), r++,
										 t = A[0,r];
										 b ||= Sort Descending( t );
								a		 i ||= Matrix(Reverse(As List( Rank Index( t ) )) );
									   );
									Eval List( { b, i } );
								  );  
							  );
							 
					 );

 

1 Comment
Ryan_Gilmore
Community Manager
Status changed to: Archived
We are archiving this request. If this is still important please comment with additional details and we will reopen. Thank you!