<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Sort a matrix in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Sort-a-matrix/m-p/85684#M38251</link>
    <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;I believe you are referring to the content that is also covered here -&amp;nbsp;&lt;A href="https://www.jmp.com/support/help/14/ranking-and-sorting.shtml" target="_blank"&gt;https://www.jmp.com/support/help/14/ranking-and-sorting.shtml&lt;/A&gt; . However, this does not expand on capturing the indices that I am looking for while performing the sort. Hopefully, I am not missing something.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 12 Dec 2018 14:16:37 GMT</pubDate>
    <dc:creator>uday_guntupalli</dc:creator>
    <dc:date>2018-12-12T14:16:37Z</dc:date>
    <item>
      <title>Sort a matrix</title>
      <link>https://community.jmp.com/t5/Discussions/Sort-a-matrix/m-p/85678#M38246</link>
      <description>&lt;P&gt;All,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Is there a way to achieve functionality similar to what is shown below :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;A = [10 -12 4 8; 6 -9 8 0; 2 3 11 -2; 1 1 9 3]&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; Upon sorting, how can i retain the original positions of the elements ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; For e.g. if i wanted to sort each column of the matrix, I can only think of doing the following:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;for(i = 1, i &amp;lt;= N cols(A), i ++,
          t = A[0,i]; 
          t1 = sort descending(t); 
    );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; Now, how can I determine the original position of the elements and retain them ?&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;A href="https://www.mathworks.com/help/matlab/ref/sort.html" target="_blank"&gt;https://www.mathworks.com/help/matlab/ref/sort.html&lt;/A&gt; - In Matlab, there is a second argument to the sort function which returns the index&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Similarly in R, you can retain the index. Wondering what is the best way to do that in JMP ?&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 11:44:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Sort-a-matrix/m-p/85678#M38246</guid>
      <dc:creator>uday_guntupalli</dc:creator>
      <dc:date>2018-12-12T11:44:13Z</dc:date>
    </item>
    <item>
      <title>Re: Sort a matrix</title>
      <link>https://community.jmp.com/t5/Discussions/Sort-a-matrix/m-p/85681#M38249</link>
      <description>Take a look at "Ranking and Sorting" in the "Data Structures, Matrices" section of the Scripting Guide</description>
      <pubDate>Wed, 12 Dec 2018 13:20:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Sort-a-matrix/m-p/85681#M38249</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-12-12T13:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: Sort a matrix</title>
      <link>https://community.jmp.com/t5/Discussions/Sort-a-matrix/m-p/85684#M38251</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;I believe you are referring to the content that is also covered here -&amp;nbsp;&lt;A href="https://www.jmp.com/support/help/14/ranking-and-sorting.shtml" target="_blank"&gt;https://www.jmp.com/support/help/14/ranking-and-sorting.shtml&lt;/A&gt; . However, this does not expand on capturing the indices that I am looking for while performing the sort. Hopefully, I am not missing something.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 14:16:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Sort-a-matrix/m-p/85684#M38251</guid>
      <dc:creator>uday_guntupalli</dc:creator>
      <dc:date>2018-12-12T14:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: Sort a matrix</title>
      <link>https://community.jmp.com/t5/Discussions/Sort-a-matrix/m-p/85698#M38254</link>
      <description>&lt;P&gt;Um, it is the ranking bit...&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 14:44:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Sort-a-matrix/m-p/85698#M38254</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2018-12-12T14:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: Sort a matrix</title>
      <link>https://community.jmp.com/t5/Discussions/Sort-a-matrix/m-p/85701#M38255</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/5358"&gt;@Mark_Bailey&lt;/a&gt;&amp;nbsp;&amp;amp;&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; I understand that it looks obvious to you that Rank() does what I want, however , here is an example of why I am asking for:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In Matlab, here is what happen when you try to sort a matrix. Apologies for pulling this example from a different platform, I tried to avoid doing that but I can't think of a better way to explain what I am after. So if you look at the values of&amp;nbsp; "I", it retains the indices&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 557px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/14829iF7B1C147EB151292/image-dimensions/557x452?v=v2" width="557" height="452" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, if I wanted to do the exact samething in JMP , is this the way you are recommending me to take, it yes, it doesn't get me the same result. Also, I would appreciate not having to use a loop for something like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;A = [10 -12 4 8; 6 -9 8 0; 2 3 11 -2; 1 1 9 3];

for(i = 1 , i &amp;lt;= N Cols(A), i++,
		t = A[0,i]; 
		t1 = Sort Descending(t); 
		ranks = Rank(t); 
   );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 15:10:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Sort-a-matrix/m-p/85701#M38255</guid>
      <dc:creator>uday_guntupalli</dc:creator>
      <dc:date>2018-12-12T15:10:46Z</dc:date>
    </item>
    <item>
      <title>Re: Sort a matrix</title>
      <link>https://community.jmp.com/t5/Discussions/Sort-a-matrix/m-p/85707#M38259</link>
      <description>&lt;P&gt;This adaption should work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;A = [10 -12 4 8; 6 -9 8 0; 2 3 11 -2; 1 1 9 3];&lt;BR /&gt;&lt;BR /&gt;sort matrix = Function( { m }, { t, b=[], i=[] },&lt;BR /&gt; For( j = 1, j &amp;lt;= N Cols( m ), j++,&lt;BR /&gt; t = A[0,j];&lt;BR /&gt; b ||= Sort Descending( t );&lt;BR /&gt; i ||= Matrix( Reverse( As List( Rank Index( t ) ) ) );&lt;BR /&gt; );&lt;BR /&gt; Eval List( { b, i } );&lt;BR /&gt;);&lt;BR /&gt;&lt;BR /&gt;{ B, I } = sort matrix( A );&lt;BR /&gt;&lt;BR /&gt;Show( A, B, I );&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 16:17:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Sort-a-matrix/m-p/85707#M38259</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2018-12-12T16:17:14Z</dc:date>
    </item>
    <item>
      <title>Re: Sort a matrix</title>
      <link>https://community.jmp.com/t5/Discussions/Sort-a-matrix/m-p/85714#M38263</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/5358"&gt;@Mark_Bailey&lt;/a&gt;,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Thank you. I will submit a request to the wish list to provide a canned function for this.&amp;nbsp; I hope in the future, JMP will come up with a way to not have to loop through the matrix. I would love to see the apply() function family from R introduced into JMP.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 18:20:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Sort-a-matrix/m-p/85714#M38263</guid>
      <dc:creator>uday_guntupalli</dc:creator>
      <dc:date>2018-12-12T18:20:42Z</dc:date>
    </item>
  </channel>
</rss>

