<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - answers and comments on Question, Sorting a list of xy pairs</title>
    <link>http://www.mapleprimes.com/questions/87699-Sorting-A-List-Of-Xy-Pairs</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Thu, 11 Jun 2026 07:32:20 GMT</lastBuildDate>
    <pubDate>Thu, 11 Jun 2026 07:32:20 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest answers and comments added to the Question, Sorting a list of xy pairs</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - answers and comments on Question, Sorting a list of xy pairs</title>
      <link>http://www.mapleprimes.com/questions/87699-Sorting-A-List-Of-Xy-Pairs</link>
    </image>
    <item>
      <title>sort</title>
      <link>http://www.mapleprimes.com/questions/87699-Sorting-A-List-Of-Xy-Pairs?ref=Feed:MaplePrimes:Sorting a list of xy pairs:Comments#answer87824</link>
      <itunes:summary>&lt;p&gt;Is this what you want?&lt;/p&gt;
&lt;pre&gt;
&amp;gt; a := [[1, 7], [2, 3], [5, 4], [1, 2], [8, 9], [7, 9], [1, 6]]:

&amp;gt; sort(a, (x, y) -&amp;gt; x[1]&amp;lt;y[1] or (x[1]=y[1] and x[2]&amp;lt;y[2]) );
           [[1, 2], [1, 6], [1, 7], [2, 3], [5, 4], [7, 9], [8, 9]]
&lt;/pre&gt;</itunes:summary>
      <description>&lt;p&gt;Is this what you want?&lt;/p&gt;
&lt;pre&gt;
&amp;gt; a := [[1, 7], [2, 3], [5, 4], [1, 2], [8, 9], [7, 9], [1, 6]]:

&amp;gt; sort(a, (x, y) -&amp;gt; x[1]&amp;lt;y[1] or (x[1]=y[1] and x[2]&amp;lt;y[2]) );
           [[1, 2], [1, 6], [1, 7], [2, 3], [5, 4], [7, 9], [8, 9]]
&lt;/pre&gt;</description>
      <guid>87824</guid>
      <pubDate>Wed, 19 May 2010 17:17:57 Z</pubDate>
      <itunes:author>pagan</itunes:author>
      <author>pagan</author>
    </item>
    <item>
      <title>sort </title>
      <link>http://www.mapleprimes.com/questions/87699-Sorting-A-List-Of-Xy-Pairs?ref=Feed:MaplePrimes:Sorting a list of xy pairs:Comments#answer87825</link>
      <itunes:summary>&lt;p&gt;Is this what you want?&lt;/p&gt;
&lt;p&gt;&amp;gt; sort(a, (x, y) -&amp;gt;`if`(x[1] = y[1], evalb(x[2] &amp;lt; y[2]), evalb(x[1] &amp;lt; y[1])));&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Scott&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;Is this what you want?&lt;/p&gt;
&lt;p&gt;&amp;gt; sort(a, (x, y) -&amp;gt;`if`(x[1] = y[1], evalb(x[2] &amp;lt; y[2]), evalb(x[1] &amp;lt; y[1])));&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Scott&lt;/p&gt;</description>
      <guid>87825</guid>
      <pubDate>Wed, 19 May 2010 17:21:51 Z</pubDate>
      <itunes:author>Scott03</itunes:author>
      <author>Scott03</author>
    </item>
    <item>
      <title>Yes, sort in ascending order for plot</title>
      <link>http://www.mapleprimes.com/questions/87699-Sorting-A-List-Of-Xy-Pairs?ref=Feed:MaplePrimes:Sorting a list of xy pairs:Comments#answer87826</link>
      <itunes:summary>&lt;p&gt;Yes, to sort them in an ascending order so plotting will be continuously increasing.&lt;/p&gt;
&lt;p&gt;Thanks for those two variations.&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;Yes, to sort them in an ascending order so plotting will be continuously increasing.&lt;/p&gt;
&lt;p&gt;Thanks for those two variations.&lt;/p&gt;</description>
      <guid>87826</guid>
      <pubDate>Wed, 19 May 2010 17:30:40 Z</pubDate>
      <itunes:author>Christopher2222</itunes:author>
      <author>Christopher2222</author>
    </item>
    <item>
      <title>sort</title>
      <link>http://www.mapleprimes.com/questions/87699-Sorting-A-List-Of-Xy-Pairs?ref=Feed:MaplePrimes:Sorting a list of xy pairs:Comments#answer87827</link>
      <itunes:summary>&lt;p&gt;In Maple 13+, sort without additional arguments should work like that,&lt;/p&gt;
&lt;pre&gt;sort(a);

       [[1, 2], [1, 6], [1, 7], [2, 3], [5, 4], [7, 9], [8, 9]]
&lt;/pre&gt;
&lt;p&gt;Alec&lt;/p&gt;
</itunes:summary>
      <description>&lt;p&gt;In Maple 13+, sort without additional arguments should work like that,&lt;/p&gt;
&lt;pre&gt;sort(a);

       [[1, 2], [1, 6], [1, 7], [2, 3], [5, 4], [7, 9], [8, 9]]
&lt;/pre&gt;
&lt;p&gt;Alec&lt;/p&gt;
</description>
      <guid>87827</guid>
      <pubDate>Wed, 19 May 2010 18:04:03 Z</pubDate>
      <itunes:author>alec</itunes:author>
      <author>alec</author>
    </item>
    <item>
      <title>evalb</title>
      <link>http://www.mapleprimes.com/questions/87699-Sorting-A-List-Of-Xy-Pairs?ref=Feed:MaplePrimes:Sorting a list of xy pairs:Comments#answer87829</link>
      <itunes:summary>&lt;p&gt;Maple will apply the evalb automatically here, so those evalb's are a (small but) unnecessary additional cost. There may be much more efficient ways to do this task for very large listlists, so it doesn't matter much here.&lt;/p&gt;
&lt;p&gt;But in general you want to avoid programming anything like this too&lt;/p&gt;
&lt;pre&gt;
if evalb(....) then ...
&lt;/pre&gt;</itunes:summary>
      <description>&lt;p&gt;Maple will apply the evalb automatically here, so those evalb's are a (small but) unnecessary additional cost. There may be much more efficient ways to do this task for very large listlists, so it doesn't matter much here.&lt;/p&gt;
&lt;p&gt;But in general you want to avoid programming anything like this too&lt;/p&gt;
&lt;pre&gt;
if evalb(....) then ...
&lt;/pre&gt;</description>
      <guid>87829</guid>
      <pubDate>Wed, 19 May 2010 18:22:05 Z</pubDate>
      <itunes:author>pagan</itunes:author>
      <author>pagan</author>
    </item>
    <item>
      <title>sorting a list of lists in Maple 12 or inferior.</title>
      <link>http://www.mapleprimes.com/questions/87699-Sorting-A-List-Of-Xy-Pairs?ref=Feed:MaplePrimes:Sorting a list of xy pairs:Comments#answer87830</link>
      <itunes:summary>&lt;p&gt;here is a solution for sorting a list of lists of numbers for Maple versions inferior to Maple 12.&lt;/p&gt;
&lt;p&gt;I&amp;nbsp;supposed that [1,2] is inferior to [1,2,1]&amp;nbsp;or [1,2,3]. etc...&lt;/p&gt;
&lt;p&gt;&amp;nbsp;plus := proc (l, d) local e, i; e := 0; for i to min(nops(l),nops(d)) do if l[i] &amp;lt; d[i] then e := l; break elif d[i] &amp;lt; l[i] then e := d; break end if end do; if e = 0 then if nops(d) &amp;lt;= nops(l) then e := d else e := l end if end if; return e end proc;&lt;/p&gt;
&lt;p&gt;plus([1,3],[1,2,3]);&lt;br /&gt;
[1, 2, 3]&lt;br /&gt;
&amp;nbsp;&lt;/p&gt;
&lt;p&gt;mini := proc (L) local x, i; x := L[1]; for i from 2 to nops(L) do x := plus(x,L[i]) end do; return x end proc;&lt;/p&gt;
&lt;p&gt;soust := proc (l, d0) local A, d, i, e, D, j; A := []; d := d0; for i to nops(l) do e := 0; D := d; for j to nops(d) do if l[i] = d[j] then e := 1; D := [seq(D[k],k = 1 .. j-1), seq(D[k],k = j+1 .. nops(D))]; break end if end do; if e = 0 then A := [op(A), l[i]] end if; d := D end do; return A end proc;&lt;/p&gt;
&lt;p&gt;ord := proc (L0) local L, A, i; L := L0; A := []; for i to nops(L) do A := [op(A), mini(L)]; L := soust(L,[A[nops(A)]]) end do; return A end proc;&lt;/p&gt;
&lt;p&gt;ord([[1,3],[1,2],[1,2,3],[3,2],[3,1],[3,1,2]]);&lt;br /&gt;
[[1, 2], [1, 2, 3], [1, 3], [3, 1], [3, 1, 2], [3, 2]]&lt;br /&gt;
&amp;nbsp;&lt;/p&gt;
&lt;p&gt;a := [[1, 7], [2, 3], [5, 4], [1, 2], [8, 9], [7, 9], [1, 6]]:ord(a);&lt;/p&gt;
&lt;p&gt;[[1, 2], [1, 6], [1, 7], [2, 3], [5, 4], [7, 9], [8, 9]]&lt;br /&gt;
&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;here is a solution for sorting a list of lists of numbers for Maple versions inferior to Maple 12.&lt;/p&gt;
&lt;p&gt;I&amp;nbsp;supposed that [1,2] is inferior to [1,2,1]&amp;nbsp;or [1,2,3]. etc...&lt;/p&gt;
&lt;p&gt;&amp;nbsp;plus := proc (l, d) local e, i; e := 0; for i to min(nops(l),nops(d)) do if l[i] &amp;lt; d[i] then e := l; break elif d[i] &amp;lt; l[i] then e := d; break end if end do; if e = 0 then if nops(d) &amp;lt;= nops(l) then e := d else e := l end if end if; return e end proc;&lt;/p&gt;
&lt;p&gt;plus([1,3],[1,2,3]);&lt;br /&gt;
[1, 2, 3]&lt;br /&gt;
&amp;nbsp;&lt;/p&gt;
&lt;p&gt;mini := proc (L) local x, i; x := L[1]; for i from 2 to nops(L) do x := plus(x,L[i]) end do; return x end proc;&lt;/p&gt;
&lt;p&gt;soust := proc (l, d0) local A, d, i, e, D, j; A := []; d := d0; for i to nops(l) do e := 0; D := d; for j to nops(d) do if l[i] = d[j] then e := 1; D := [seq(D[k],k = 1 .. j-1), seq(D[k],k = j+1 .. nops(D))]; break end if end do; if e = 0 then A := [op(A), l[i]] end if; d := D end do; return A end proc;&lt;/p&gt;
&lt;p&gt;ord := proc (L0) local L, A, i; L := L0; A := []; for i to nops(L) do A := [op(A), mini(L)]; L := soust(L,[A[nops(A)]]) end do; return A end proc;&lt;/p&gt;
&lt;p&gt;ord([[1,3],[1,2],[1,2,3],[3,2],[3,1],[3,1,2]]);&lt;br /&gt;
[[1, 2], [1, 2, 3], [1, 3], [3, 1], [3, 1, 2], [3, 2]]&lt;br /&gt;
&amp;nbsp;&lt;/p&gt;
&lt;p&gt;a := [[1, 7], [2, 3], [5, 4], [1, 2], [8, 9], [7, 9], [1, 6]]:ord(a);&lt;/p&gt;
&lt;p&gt;[[1, 2], [1, 6], [1, 7], [2, 3], [5, 4], [7, 9], [8, 9]]&lt;br /&gt;
&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
      <guid>87830</guid>
      <pubDate>Wed, 19 May 2010 21:43:44 Z</pubDate>
      <itunes:author>xavier</itunes:author>
      <author>xavier</author>
    </item>
  </channel>
</rss>