<?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: How to sort a NotesDocumentCollection in Lotusscript</title>
	<atom:link href="http://blog.tjitjing.com/index.php/2006/05/how-to-sort-notesdocumentcollection-in.html/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.tjitjing.com/index.php/2006/05/how-to-sort-notesdocumentcollection-in.html</link>
	<description>This is my blog on technology related things and maybe some other stuff too...</description>
	<lastBuildDate>Sun, 15 Jan 2012 09:50:28 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Rodrigo</title>
		<link>http://blog.tjitjing.com/index.php/2006/05/how-to-sort-notesdocumentcollection-in.html#comment-43229</link>
		<dc:creator>Rodrigo</dc:creator>
		<pubDate>Thu, 08 Dec 2011 13:01:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tjitjing.com/index.php/2006/05/how-to-sort-a-notesdocumentcollection-in-lotusscript.html#comment-43229</guid>
		<description>Great function.
Thanks for share with us.</description>
		<content:encoded><![CDATA[<p>Great function.<br />
Thanks for share with us.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael W</title>
		<link>http://blog.tjitjing.com/index.php/2006/05/how-to-sort-notesdocumentcollection-in.html#comment-27074</link>
		<dc:creator>Michael W</dc:creator>
		<pubDate>Fri, 08 Apr 2011 17:37:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tjitjing.com/index.php/2006/05/how-to-sort-a-notesdocumentcollection-in-lotusscript.html#comment-27074</guid>
		<description>You know it&#039;s some good code when after all these years, IT STILL WORKS !!!!

My project just got completed faster than expected thanks to you. Thanks again for posting.</description>
		<content:encoded><![CDATA[<p>You know it&#8217;s some good code when after all these years, IT STILL WORKS !!!!</p>
<p>My project just got completed faster than expected thanks to you. Thanks again for posting.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Darkfire</title>
		<link>http://blog.tjitjing.com/index.php/2006/05/how-to-sort-notesdocumentcollection-in.html#comment-21304</link>
		<dc:creator>Darkfire</dc:creator>
		<pubDate>Wed, 19 Jan 2011 13:42:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tjitjing.com/index.php/2006/05/how-to-sort-a-notesdocumentcollection-in-lotusscript.html#comment-21304</guid>
		<description>You made my Day!!!
Thank you</description>
		<content:encoded><![CDATA[<p>You made my Day!!!<br />
Thank you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sorting a NotesDocumentCollection by multiple field values (Show&#8217;n Tell Thursday) &#124; Per Henrik Lausten</title>
		<link>http://blog.tjitjing.com/index.php/2006/05/how-to-sort-notesdocumentcollection-in.html#comment-12623</link>
		<dc:creator>Sorting a NotesDocumentCollection by multiple field values (Show&#8217;n Tell Thursday) &#124; Per Henrik Lausten</dc:creator>
		<pubDate>Sun, 13 Jun 2010 06:46:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tjitjing.com/index.php/2006/05/how-to-sort-a-notesdocumentcollection-in-lotusscript.html#comment-12623</guid>
		<description>[...] Max Flodén has created a function that does exactly that: sorts a NotesDocumentCollection by one or more field values. But the code from Max uses Evaluate and @Sort to do the actual sorting - and therefore has problems with quotes in the values and apparently also a problem with large collections (see comments to his post). [...]</description>
		<content:encoded><![CDATA[<p>[...] Max Flodén has created a function that does exactly that: sorts a NotesDocumentCollection by one or more field values. But the code from Max uses Evaluate and @Sort to do the actual sorting &#8211; and therefore has problems with quotes in the values and apparently also a problem with large collections (see comments to his post). [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Atul Yadav</title>
		<link>http://blog.tjitjing.com/index.php/2006/05/how-to-sort-notesdocumentcollection-in.html#comment-12528</link>
		<dc:creator>Atul Yadav</dc:creator>
		<pubDate>Thu, 03 Jun 2010 14:02:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tjitjing.com/index.php/2006/05/how-to-sort-a-notesdocumentcollection-in-lotusscript.html#comment-12528</guid>
		<description>It&#039;s a great generic function to sort the collection.
Congrats for the good work done.
But i have one query in this function.I need to sort a list which consisits of only numbers . for example list will contain numbers such as 012999 and 003323..your function is not working in such scenario.
Request you to suggest a solution for this.</description>
		<content:encoded><![CDATA[<p>It&#8217;s a great generic function to sort the collection.<br />
Congrats for the good work done.<br />
But i have one query in this function.I need to sort a list which consisits of only numbers . for example list will contain numbers such as 012999 and 003323..your function is not working in such scenario.<br />
Request you to suggest a solution for this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Singer</title>
		<link>http://blog.tjitjing.com/index.php/2006/05/how-to-sort-notesdocumentcollection-in.html#comment-591</link>
		<dc:creator>Mark Singer</dc:creator>
		<pubDate>Thu, 07 Aug 2008 17:45:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tjitjing.com/index.php/2006/05/how-to-sort-a-notesdocumentcollection-in-lotusscript.html#comment-591</guid>
		<description>Thanks for doing the work.&lt;br/&gt;&lt;br/&gt;Here&#039;s an idea.&lt;br/&gt;&lt;br/&gt;By changing the new doc collection creation line to &lt;br/&gt;&lt;br/&gt; Set collSorted = coll.Parent.Views(0).GetAllDocumentsByKey(fakesearchstring)&lt;br/&gt;&lt;br/&gt;Instead we just grab the first available view in the db. Because we don&#039;t use the view other than to create the doc collection, we can use anything.&lt;br/&gt;&lt;br/&gt;By making this small change, you don&#039;t have to pass in or code any db names or view names. Makes the function a better standalone candidate for a utility library.&lt;br/&gt;&lt;br/&gt;Cheers and thanks!</description>
		<content:encoded><![CDATA[<p>Thanks for doing the work.</p>
<p>Here&#8217;s an idea.</p>
<p>By changing the new doc collection creation line to </p>
<p> Set collSorted = coll.Parent.Views(0).GetAllDocumentsByKey(fakesearchstring)</p>
<p>Instead we just grab the first available view in the db. Because we don&#8217;t use the view other than to create the doc collection, we can use anything.</p>
<p>By making this small change, you don&#8217;t have to pass in or code any db names or view names. Makes the function a better standalone candidate for a utility library.</p>
<p>Cheers and thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://blog.tjitjing.com/index.php/2006/05/how-to-sort-notesdocumentcollection-in.html#comment-477</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Wed, 02 May 2007 04:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tjitjing.com/index.php/2006/05/how-to-sort-a-notesdocumentcollection-in-lotusscript.html#comment-477</guid>
		<description>After sorting, how can we go about inserting page breaks between the sorted data? E.G.  between clients?  I am using this script to sort dozens of clients and it would be much easier to have page breaks between the clients</description>
		<content:encoded><![CDATA[<p>After sorting, how can we go about inserting page breaks between the sorted data? E.G.  between clients?  I am using this script to sort dozens of clients and it would be much easier to have page breaks between the clients</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://blog.tjitjing.com/index.php/2006/05/how-to-sort-notesdocumentcollection-in.html#comment-443</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Sat, 06 Jan 2007 21:14:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tjitjing.com/index.php/2006/05/how-to-sort-a-notesdocumentcollection-in-lotusscript.html#comment-443</guid>
		<description>Great job!  This works after several others I tried failed.  I suggest having the view name and fake search string passed in as a parameter so that the function doesn&#039;t have to be edited and so that lazy coders like me don&#039;t have to read the function before trying to run it.  Haha.  Thanks for the contribution.  What do I owe you?  Rob Pinion</description>
		<content:encoded><![CDATA[<p>Great job!  This works after several others I tried failed.  I suggest having the view name and fake search string passed in as a parameter so that the function doesn&#8217;t have to be edited and so that lazy coders like me don&#8217;t have to read the function before trying to run it.  Haha.  Thanks for the contribution.  What do I owe you?  Rob Pinion</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://blog.tjitjing.com/index.php/2006/05/how-to-sort-notesdocumentcollection-in.html#comment-432</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Fri, 24 Nov 2006 23:06:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tjitjing.com/index.php/2006/05/how-to-sort-a-notesdocumentcollection-in-lotusscript.html#comment-432</guid>
		<description>Great. I modified the code to use a variants and them applied quicksort function to do the sorting. &lt;br /&gt;&lt;br /&gt;Here is how I uploaded to a variant&lt;br /&gt;dim tempdoc as NotesDocument&lt;br /&gt;dim tempItem as NotesItem&lt;br /&gt;Dim varSort as Variant&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Set tempdoc = db.CreateDocument&lt;br /&gt; tempdoc.ArrSort = &quot;&quot;&lt;br /&gt; Set tempitem = tempDoc.GetFirstItem(&quot;ArrSort&quot;)&lt;br /&gt; For i = 0 To coll.Count - 1&lt;br /&gt;  strSort = &quot;&quot;&lt;br /&gt;  For n = Lbound(fieldnames) To Ubound(fieldnames) + 1&lt;br /&gt;   strSort = strSort &amp; Left(arrSort(i,n) &amp; Space(arrFieldValueLength(n)), arrFieldValueLength(n))&lt;br /&gt;  Next n&lt;br /&gt;  Call tempitem.AppendToTextList(strSort )&lt;br /&gt; Next i&lt;br /&gt;&lt;br /&gt;then call the selection sort function&lt;br /&gt; varSort = tempItem.Values&lt;br /&gt; Call SelectionSort(varSort )&lt;br /&gt;&lt;br /&gt;and finally, rebuilt the collection&lt;br /&gt;&lt;br /&gt;Set collSorted = coll.Parent.GetView(viewname).GetAllDocumentsByKey(fakesearchstring)&lt;br /&gt; &lt;br /&gt; For i = 0 To Ubound(varSort)&lt;br /&gt;  Set doc = db.GetDocumentByUNID(Right(varSort(i), 32))&lt;br /&gt;  Call collSorted.AddDocument(doc)&lt;br /&gt; Next i&lt;br /&gt;&lt;br /&gt;Here is the selection sort function&lt;br /&gt;&lt;br /&gt;Sub SelectionSort (MyArray As Variant) &lt;br /&gt; &#039; Selection Sort, &quot;Data Structures Using C&quot;, Tenenbaum, ..., p. 337.&lt;br /&gt; If Ubound (MyArray) &lt;= 0 Then Exit Sub &lt;br /&gt; nElem = Ubound (MyArray) + 1&lt;br /&gt; For i = nElem - 1 To 1 Step -1&lt;br /&gt;  Large$ = MyArray(0)&lt;br /&gt;  indx = 0&lt;br /&gt;  For j = 1 To nElem&lt;br /&gt;   If j &gt; i Then Exit For&lt;br /&gt;   If Strcompare(MyArray(j), Large$) &gt;0 Then &#039; Ascending&lt;br /&gt;    Large$ = MyArray(j)&lt;br /&gt;    indx = j&lt;br /&gt;   End If &lt;br /&gt;  Next &lt;br /&gt;  MyArray(indx) = MyArray(i)&lt;br /&gt;  MyArray(i) = Large$&lt;br /&gt; Next&lt;br /&gt;End Sub</description>
		<content:encoded><![CDATA[<p>Great. I modified the code to use a variants and them applied quicksort function to do the sorting. </p>
<p>Here is how I uploaded to a variant<br />dim tempdoc as NotesDocument<br />dim tempItem as NotesItem<br />Dim varSort as Variant</p>
<p>Set tempdoc = db.CreateDocument<br /> tempdoc.ArrSort = &#8220;&#8221;<br /> Set tempitem = tempDoc.GetFirstItem(&#8220;ArrSort&#8221;)<br /> For i = 0 To coll.Count &#8211; 1<br />  strSort = &#8220;&#8221;<br />  For n = Lbound(fieldnames) To Ubound(fieldnames) + 1<br />   strSort = strSort &#038; Left(arrSort(i,n) &#038; Space(arrFieldValueLength(n)), arrFieldValueLength(n))<br />  Next n<br />  Call tempitem.AppendToTextList(strSort )<br /> Next i</p>
<p>then call the selection sort function<br /> varSort = tempItem.Values<br /> Call SelectionSort(varSort )</p>
<p>and finally, rebuilt the collection</p>
<p>Set collSorted = coll.Parent.GetView(viewname).GetAllDocumentsByKey(fakesearchstring)</p>
<p> For i = 0 To Ubound(varSort)<br />  Set doc = db.GetDocumentByUNID(Right(varSort(i), 32))<br />  Call collSorted.AddDocument(doc)<br /> Next i</p>
<p>Here is the selection sort function</p>
<p>Sub SelectionSort (MyArray As Variant) <br /> &#8216; Selection Sort, &#8220;Data Structures Using C&#8221;, Tenenbaum, &#8230;, p. 337.<br /> If Ubound (MyArray) < = 0 Then Exit Sub <br /> nElem = Ubound (MyArray) + 1<br /> For i = nElem &#8211; 1 To 1 Step -1<br />  Large$ = MyArray(0)<br />  indx = 0<br />  For j = 1 To nElem<br />   If j > i Then Exit For<br />   If Strcompare(MyArray(j), Large$) >0 Then &#8216; Ascending<br />    Large$ = MyArray(j)<br />    indx = j<br />   End If <br />  Next <br />  MyArray(indx) = MyArray(i)<br />  MyArray(i) = Large$<br /> Next<br />End Sub</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SN</title>
		<link>http://blog.tjitjing.com/index.php/2006/05/how-to-sort-notesdocumentcollection-in.html#comment-428</link>
		<dc:creator>SN</dc:creator>
		<pubDate>Wed, 15 Nov 2006 18:05:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tjitjing.com/index.php/2006/05/how-to-sort-a-notesdocumentcollection-in-lotusscript.html#comment-428</guid>
		<description>Thank you very much.&lt;br/&gt;This function works fine.</description>
		<content:encoded><![CDATA[<p>Thank you very much.<br />This function works fine.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

