<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Sorting PL/SQL Collections, the hard way, the intermediate way and the quite simple way (part one)</title>
	<atom:link href="http://technology.amis.nl/2006/05/31/sorting-plsql-collections-the-hard-way-the-intermediate-way-and-the-quite-simple-way-part-one/feed/" rel="self" type="application/rss+xml" />
	<link>http://technology.amis.nl/2006/05/31/sorting-plsql-collections-the-hard-way-the-intermediate-way-and-the-quite-simple-way-part-one/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=sorting-plsql-collections-the-hard-way-the-intermediate-way-and-the-quite-simple-way-part-one</link>
	<description></description>
	<lastBuildDate>Fri, 12 Apr 2013 10:04:09 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>By: Michael</title>
		<link>http://technology.amis.nl/2006/05/31/sorting-plsql-collections-the-hard-way-the-intermediate-way-and-the-quite-simple-way-part-one/#comment-3354</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Thu, 20 Sep 2007 20:35:22 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=1214#comment-3354</guid>
		<description><![CDATA[Hi,

Thank you for your code. Can you also advice how to sort in desc order?

Thank you again.
Michael]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Thank you for your code. Can you also advice how to sort in desc order?</p>
<p>Thank you again.<br />
Michael</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vizith</title>
		<link>http://technology.amis.nl/2006/05/31/sorting-plsql-collections-the-hard-way-the-intermediate-way-and-the-quite-simple-way-part-one/#comment-3353</link>
		<dc:creator>Vizith</dc:creator>
		<pubDate>Mon, 26 Feb 2007 05:58:11 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=1214#comment-3353</guid>
		<description><![CDATA[i guyz i tried to  develop a number puzzle forms6i .. and am in a half way strucked with logic in it .. so can any one help me out to finish my project.

i added the followin code

declare

temp varchar2(40);
		lbl varchar2(40);
begin
		lbl:=get_item_property(name_in(&#039;system.trigger_item&#039;),label);
	temp:= :system.trigger_item;
	if get_item_property(temp,VISIBLE)= &#039;TRUE&#039; then
		set_item_property(:parameter.HIDENUM,VISIBLE,PROPERTY_TRUE);
		set_item_property(:parameter.HIDENUM,ENABLED,PROPERTY_TRUE);
		set_item_property(:parameter.HIDENUM,label,lbl);
		go_item(:parameter.HIDENUM);
		set_item_property(temp,VISIBLE,PROPERTY_FALSE);
		:parameter.HIDENUM:=temp;
	end if;
	/*if get_item_property(&#039;number_game.TWO&#039;,displayed)=&#039;TRUE&#039; then
		set_item_property(&#039;number_game.TWO&#039;,displayed,&#039;FALSE&#039;);
	end if;
	if  get_item_property(&#039;number_game.THREE&#039;,displayed)=&#039;TRUE&#039; then
		set_item_property(&#039;number_game.THREE&#039;,displayed,&#039;FALSE&#039;);
		end if;*/
if lbl =&#039;EXIT&#039; then exit_form(no_validate);
end if;
end;]]></description>
		<content:encoded><![CDATA[<p>i guyz i tried to  develop a number puzzle forms6i .. and am in a half way strucked with logic in it .. so can any one help me out to finish my project.</p>
<p>i added the followin code</p>
<p>declare</p>
<p>temp varchar2(40);<br />
		lbl varchar2(40);<br />
begin<br />
		lbl:=get_item_property(name_in(&#8216;system.trigger_item&#8217;),label);<br />
	temp:= :system.trigger_item;<br />
	if get_item_property(temp,VISIBLE)= &#8216;TRUE&#8217; then<br />
		set_item_property(:parameter.HIDENUM,VISIBLE,PROPERTY_TRUE);<br />
		set_item_property(:parameter.HIDENUM,ENABLED,PROPERTY_TRUE);<br />
		set_item_property(:parameter.HIDENUM,label,lbl);<br />
		go_item(:parameter.HIDENUM);<br />
		set_item_property(temp,VISIBLE,PROPERTY_FALSE);<br />
		:parameter.HIDENUM:=temp;<br />
	end if;<br />
	/*if get_item_property(&#8216;number_game.TWO&#8217;,displayed)=&#8217;TRUE&#8217; then<br />
		set_item_property(&#8216;number_game.TWO&#8217;,displayed,&#8217;FALSE&#8217;);<br />
	end if;<br />
	if  get_item_property(&#8216;number_game.THREE&#8217;,displayed)=&#8217;TRUE&#8217; then<br />
		set_item_property(&#8216;number_game.THREE&#8217;,displayed,&#8217;FALSE&#8217;);<br />
		end if;*/<br />
if lbl =&#8217;EXIT&#8217; then exit_form(no_validate);<br />
end if;<br />
end;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Miquel</title>
		<link>http://technology.amis.nl/2006/05/31/sorting-plsql-collections-the-hard-way-the-intermediate-way-and-the-quite-simple-way-part-one/#comment-3352</link>
		<dc:creator>Miquel</dc:creator>
		<pubDate>Wed, 01 Nov 2006 21:59:00 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=1214#comment-3352</guid>
		<description><![CDATA[With a little adjustement (2 dimension table for sorting) it works for duplicates:
/* Formatted on 2006/11/01 20:11 (Formatter Plus v4.8.5) */
DECLARE
-- define and initialize a simple Nested Table Collection
   TYPE num_tbl IS TABLE OF NUMBER;

   l_num_tbl   num_tbl := num_tbl (6, 12, 9, 1, 54, 21, 11, 2, 12, 12, 11);
   l_idx       INTEGER;
   i           INTEGER;
BEGIN
   DECLARE
-- here is where the sorting magic starts
-- we create an Associative Array that is indexed by binary_integer
-- we know that this collections keys (the only thing we care about in this case)
-- will always be kept in sorted order
      TYPE num_aat_t IS TABLE OF NUMBER
         INDEX BY BINARY_INTEGER;


      TYPE num_aat_t2 IS TABLE OF num_aat_t
         INDEX BY BINARY_INTEGER;
-- two dimension table  to handle duplicates
      l_num_aat   num_aat_t2;
   BEGIN
      l_idx := l_num_tbl.FIRST;

-- loop over all elements in the l_num_tbl collection
-- that we want to sort. Use every element in l_num_tbl
-- as a key for the l_num_aat associative array. Associate
-- the key with a meaningless value; we do not care about
-- the value in this case.
      LOOP
         i := 1;

         -- if duplicate increment second dimension
         WHILE l_num_aat.EXISTS (l_num_tbl (l_idx))
          AND l_num_aat (l_num_tbl (l_idx)).EXISTS (i)
         LOOP
            i := i + 1;
         END LOOP;

         l_num_aat (l_num_tbl (l_idx)) (i) := 0;
         l_idx := l_num_tbl.NEXT (l_idx);
         EXIT WHEN l_idx IS NULL;
      END LOOP;

-- remove all elements from l_num_tbl
      l_num_tbl.DELETE;
-- start repopulating l_num_tbl - in the proper order -
-- from the sorted collection of keys in the l_num_aat collection
      l_idx := l_num_aat.FIRST;

      LOOP
         FOR i IN 1 .. l_num_aat (l_idx).LAST
         LOOP
            l_num_tbl.EXTEND;
            l_num_tbl (l_num_tbl.LAST) := l_idx;
         END LOOP;

         l_idx := l_num_aat.NEXT (l_idx);
         EXIT WHEN l_idx IS NULL;
      END LOOP;
   END;

-- DONE! At this point, l_num_tbl is properly sorted
   l_idx := l_num_tbl.FIRST;

   LOOP
      DBMS_OUTPUT.put_line (&#039; ** &#039; &#124;&#124; l_num_tbl (l_idx));
      l_idx := l_num_tbl.NEXT (l_idx);
      EXIT WHEN l_idx IS NULL;
   END LOOP;
END;]]></description>
		<content:encoded><![CDATA[<p>With a little adjustement (2 dimension table for sorting) it works for duplicates:<br />
/* Formatted on 2006/11/01 20:11 (Formatter Plus v4.8.5) */<br />
DECLARE<br />
&#8211; define and initialize a simple Nested Table Collection<br />
   TYPE num_tbl IS TABLE OF NUMBER;</p>
<p>   l_num_tbl   num_tbl := num_tbl (6, 12, 9, 1, 54, 21, 11, 2, 12, 12, 11);<br />
   l_idx       INTEGER;<br />
   i           INTEGER;<br />
BEGIN<br />
   DECLARE<br />
&#8211; here is where the sorting magic starts<br />
&#8211; we create an Associative Array that is indexed by binary_integer<br />
&#8211; we know that this collections keys (the only thing we care about in this case)<br />
&#8211; will always be kept in sorted order<br />
      TYPE num_aat_t IS TABLE OF NUMBER<br />
         INDEX BY BINARY_INTEGER;</p>
<p>      TYPE num_aat_t2 IS TABLE OF num_aat_t<br />
         INDEX BY BINARY_INTEGER;<br />
&#8211; two dimension table  to handle duplicates<br />
      l_num_aat   num_aat_t2;<br />
   BEGIN<br />
      l_idx := l_num_tbl.FIRST;</p>
<p>&#8211; loop over all elements in the l_num_tbl collection<br />
&#8211; that we want to sort. Use every element in l_num_tbl<br />
&#8211; as a key for the l_num_aat associative array. Associate<br />
&#8211; the key with a meaningless value; we do not care about<br />
&#8211; the value in this case.<br />
      LOOP<br />
         i := 1;</p>
<p>         &#8212; if duplicate increment second dimension<br />
         WHILE l_num_aat.EXISTS (l_num_tbl (l_idx))<br />
          AND l_num_aat (l_num_tbl (l_idx)).EXISTS (i)<br />
         LOOP<br />
            i := i + 1;<br />
         END LOOP;</p>
<p>         l_num_aat (l_num_tbl (l_idx)) (i) := 0;<br />
         l_idx := l_num_tbl.NEXT (l_idx);<br />
         EXIT WHEN l_idx IS NULL;<br />
      END LOOP;</p>
<p>&#8211; remove all elements from l_num_tbl<br />
      l_num_tbl.DELETE;<br />
&#8211; start repopulating l_num_tbl &#8211; in the proper order -<br />
&#8211; from the sorted collection of keys in the l_num_aat collection<br />
      l_idx := l_num_aat.FIRST;</p>
<p>      LOOP<br />
         FOR i IN 1 .. l_num_aat (l_idx).LAST<br />
         LOOP<br />
            l_num_tbl.EXTEND;<br />
            l_num_tbl (l_num_tbl.LAST) := l_idx;<br />
         END LOOP;</p>
<p>         l_idx := l_num_aat.NEXT (l_idx);<br />
         EXIT WHEN l_idx IS NULL;<br />
      END LOOP;<br />
   END;</p>
<p>&#8211; DONE! At this point, l_num_tbl is properly sorted<br />
   l_idx := l_num_tbl.FIRST;</p>
<p>   LOOP<br />
      DBMS_OUTPUT.put_line (&#8216; ** &#8216; || l_num_tbl (l_idx));<br />
      l_idx := l_num_tbl.NEXT (l_idx);<br />
      EXIT WHEN l_idx IS NULL;<br />
   END LOOP;<br />
END;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ziya Åženol</title>
		<link>http://technology.amis.nl/2006/05/31/sorting-plsql-collections-the-hard-way-the-intermediate-way-and-the-quite-simple-way-part-one/#comment-3351</link>
		<dc:creator>Ziya Åženol</dc:creator>
		<pubDate>Thu, 03 Aug 2006 15:28:58 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=1214#comment-3351</guid>
		<description><![CDATA[Thanks for this example]]></description>
		<content:encoded><![CDATA[<p>Thanks for this example</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: firefight</title>
		<link>http://technology.amis.nl/2006/05/31/sorting-plsql-collections-the-hard-way-the-intermediate-way-and-the-quite-simple-way-part-one/#comment-3350</link>
		<dc:creator>firefight</dc:creator>
		<pubDate>Sun, 09 Jul 2006 20:56:03 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=1214#comment-3350</guid>
		<description><![CDATA[The source of the problem is that PL/SQL is severly lacking in many areas, e.g. there&#039;s no language support for casting the record type to a generic type, and implementing a &quot;Comparable&quot; interface, al la Java &amp; Collections.sort.

It being designed after Pascal led to so many of the problems with type system.]]></description>
		<content:encoded><![CDATA[<p>The source of the problem is that PL/SQL is severly lacking in many areas, e.g. there&#8217;s no language support for casting the record type to a generic type, and implementing a &#8220;Comparable&#8221; interface, al la Java &amp; Collections.sort.</p>
<p>It being designed after Pascal led to so many of the problems with type system.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aino</title>
		<link>http://technology.amis.nl/2006/05/31/sorting-plsql-collections-the-hard-way-the-intermediate-way-and-the-quite-simple-way-part-one/#comment-3349</link>
		<dc:creator>Aino</dc:creator>
		<pubDate>Wed, 31 May 2006 12:58:15 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=1214#comment-3349</guid>
		<description><![CDATA[Another pitfall of this approach is that duplicates will disappear from the collection and will probably cause some unexpected behaviour with &#039;reference swapping&#039;.]]></description>
		<content:encoded><![CDATA[<p>Another pitfall of this approach is that duplicates will disappear from the collection and will probably cause some unexpected behaviour with &#8216;reference swapping&#8217;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lucas Jellema</title>
		<link>http://technology.amis.nl/2006/05/31/sorting-plsql-collections-the-hard-way-the-intermediate-way-and-the-quite-simple-way-part-one/#comment-3348</link>
		<dc:creator>Lucas Jellema</dc:creator>
		<pubDate>Wed, 31 May 2006 10:31:39 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=1214#comment-3348</guid>
		<description><![CDATA[Gary,

I can understand your hesitation. I think the approach outlined in the next installment on Sorting PL/SQL Collections may appeal more to you. See &lt;a href=&quot;http://technology.amis.nl/blog/?p=1217&quot; rel=&quot;nofollow&quot;&gt;Sorting PL/SQL Collections, the quite simple way (part two: Have the SQL Engine do the heavy lifting)&lt;/a&gt;]]></description>
		<content:encoded><![CDATA[<p>Gary,</p>
<p>I can understand your hesitation. I think the approach outlined in the next installment on Sorting PL/SQL Collections may appeal more to you. See <a href="http://technology.amis.nl/blog/?p=1217" rel="nofollow">Sorting PL/SQL Collections, the quite simple way (part two: Have the SQL Engine do the heavy lifting)</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Francois</title>
		<link>http://technology.amis.nl/2006/05/31/sorting-plsql-collections-the-hard-way-the-intermediate-way-and-the-quite-simple-way-part-one/#comment-3347</link>
		<dc:creator>Francois</dc:creator>
		<pubDate>Wed, 31 May 2006 06:42:28 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=1214#comment-3347</guid>
		<description><![CDATA[Brilliant, as allways. I&#039;m waiting for the part 2  ;o)]]></description>
		<content:encoded><![CDATA[<p>Brilliant, as allways. I&#8217;m waiting for the part 2  ;o)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gary</title>
		<link>http://technology.amis.nl/2006/05/31/sorting-plsql-collections-the-hard-way-the-intermediate-way-and-the-quite-simple-way-part-one/#comment-3346</link>
		<dc:creator>Gary</dc:creator>
		<pubDate>Wed, 31 May 2006 01:15:29 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=1214#comment-3346</guid>
		<description><![CDATA[&quot;alphabetical order &quot;
This is the bit that has worried me. I haven&#039;t found a document reference to the actual ordering sequence. I&#039;ve assumed that it basic ASCII, so you&#039;d get &#039;a&#039; sorted after &#039;A&#039; and &#039;B&#039;. I haven&#039;t tested against a machine that is natively EBCDIC, which has &#039;a&#039; before &#039;A&#039; and &#039;B&#039;.
And then there&#039;s multilingual sorts....
Just something to bear in mind (and test) if appropriate to your situation.]]></description>
		<content:encoded><![CDATA[<p>&#8220;alphabetical order &#8221;<br />
This is the bit that has worried me. I haven&#8217;t found a document reference to the actual ordering sequence. I&#8217;ve assumed that it basic ASCII, so you&#8217;d get &#8216;a&#8217; sorted after &#8216;A&#8217; and &#8216;B&#8217;. I haven&#8217;t tested against a machine that is natively EBCDIC, which has &#8216;a&#8217; before &#8216;A&#8217; and &#8216;B&#8217;.<br />
And then there&#8217;s multilingual sorts&#8230;.<br />
Just something to bear in mind (and test) if appropriate to your situation.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
