tag:blogger.com,1999:blog-26775512.post114902475568023110..comments2008-08-12T01:06:13.158+02:00Comments on Tjitjing Blog: How to sort a NotesDocumentCollection in Lotusscri...Max Flodénhttp://www.blogger.com/profile/14422190564367108454noreply@blogger.comBlogger12125tag:blogger.com,1999:blog-26775512.post-87548729067575612322008-08-07T19:45:00.000+02:002008-08-07T19:45:00.000+02:00Thanks for doing the work.Here's an idea.By changi...Thanks for doing the work.<BR/><BR/>Here's an idea.<BR/><BR/>By changing the new doc collection creation line to <BR/><BR/> Set collSorted = coll.Parent.Views(0).GetAllDocumentsByKey(fakesearchstring)<BR/><BR/>Instead we just grab the first available view in the db. Because we don't use the view other than to create the doc collection, we can use anything.<BR/><BR/>By making this small change, you don't have to pass in or code any db names or view names. Makes the function a better standalone candidate for a utility library.<BR/><BR/>Cheers and thanks!Mark Singernoreply@blogger.comtag:blogger.com,1999:blog-26775512.post-39121268687738442892007-05-02T06:58:00.000+02:002007-05-02T06:58:00.000+02:00After sorting, how can we go about inserting page ...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 clientsAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-26775512.post-15802476683884857732007-01-06T22:14:00.000+01:002007-01-06T22:14:00.000+01:00Great job! This works after several others I trie...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't have to be edited and so that lazy coders like me don't have to read the function before trying to run it. Haha. Thanks for the contribution. What do I owe you? Rob PinionAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-26775512.post-10769475687655391832006-11-25T00:06:00.000+01:002006-11-25T00:06:00.000+01:00Great. I modified the code to use a variants and t...Great. I modified the code to use a variants and them applied quicksort function to do the sorting. <br /><br />Here is how I uploaded to a variant<br />dim tempdoc as NotesDocument<br />dim tempItem as NotesItem<br />Dim varSort as Variant<br /><br /><br />Set tempdoc = db.CreateDocument<br /> tempdoc.ArrSort = ""<br /> Set tempitem = tempDoc.GetFirstItem("ArrSort")<br /> For i = 0 To coll.Count - 1<br /> strSort = ""<br /> For n = Lbound(fieldnames) To Ubound(fieldnames) + 1<br /> strSort = strSort & Left(arrSort(i,n) & Space(arrFieldValueLength(n)), arrFieldValueLength(n))<br /> Next n<br /> Call tempitem.AppendToTextList(strSort )<br /> Next i<br /><br />then call the selection sort function<br /> varSort = tempItem.Values<br /> Call SelectionSort(varSort )<br /><br />and finally, rebuilt the collection<br /><br />Set collSorted = coll.Parent.GetView(viewname).GetAllDocumentsByKey(fakesearchstring)<br /> <br /> For i = 0 To Ubound(varSort)<br /> Set doc = db.GetDocumentByUNID(Right(varSort(i), 32))<br /> Call collSorted.AddDocument(doc)<br /> Next i<br /><br />Here is the selection sort function<br /><br />Sub SelectionSort (MyArray As Variant) <br /> ' Selection Sort, "Data Structures Using C", Tenenbaum, ..., p. 337.<br /> If Ubound (MyArray) <= 0 Then Exit Sub <br /> nElem = Ubound (MyArray) + 1<br /> For i = nElem - 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 ' 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 SubAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-26775512.post-1163613915491040342006-11-15T19:05:00.000+01:002006-11-15T19:05:00.000+01:00Thank you very much.This function works fine.Thank you very much.<BR/>This function works fine.SNnoreply@blogger.comtag:blogger.com,1999:blog-26775512.post-1161850304395693832006-10-26T10:11:00.000+02:002006-10-26T10:11:00.000+02:00Hi Max, I have updated your great sorting routine ...Hi Max, I have updated your great sorting routine to use Shell sort instead of @Sort. The Shell sort routine is based on Joe Littons work.<BR/><BR/>Please see:<BR/>http://per.lausten.dk/blog/2006/10/sorting-notesdocumentcollection-by.htmlPer Henrik Laustenhttp://www.blogger.com/profile/17041679642913117588noreply@blogger.comtag:blogger.com,1999:blog-26775512.post-1156237126213645522006-08-22T10:58:00.000+02:002006-08-22T10:58:00.000+02:00Adrian - not exactly sure what you mean. This func...Adrian - not exactly sure what you mean. This function is for sorting a NotesDocumentCollection, how does view.GetAllEntriesByKey apply to that?Max Flodénhttp://www.blogger.com/profile/14422190564367108454noreply@blogger.comtag:blogger.com,1999:blog-26775512.post-1155820494560121512006-08-17T15:14:00.000+02:002006-08-17T15:14:00.000+02:00And you think this script is faster than view.GetA...And you think this script is faster than view.GetAllEntriesByKey(). I see many For Next loops in this script who are slowing the program. I have a 25.000 documents view, and GetAllEntriesByKey is working mutch better.Adriannoreply@blogger.comtag:blogger.com,1999:blog-26775512.post-1152108444798591862006-07-05T16:07:00.000+02:002006-07-05T16:07:00.000+02:00Ok, thanks. I have used it on about 10k document v...Ok, thanks. I have used it on about 10k document views at most but I would guess that the @Sort function has some limitation to what it can take in or the limitation may be with Evaluate. I did a quick search in the documentation but did not find anything, I would guess it's the good old 64k limit... (More on <A HREF="http://www-12.lotus.com/ldd/doc/domino_notes/7.0/help7_client.nsf/855dc7fcfd5fec9a85256b870069c0ab/a76a41cdff5197928525704a004da602?OpenDocument" REL="nofollow">Lotus Notes limitations in the Notes client help database</A>)<BR/><BR/>Of course you can always replace @Sort with your favourite Lotusscript sort routine Lotusscript, or Google and you will find many.Max Flodénhttp://www.blogger.com/profile/14422190564367108454noreply@blogger.comtag:blogger.com,1999:blog-26775512.post-1151584746676220842006-06-29T14:39:00.000+02:002006-06-29T14:39:00.000+02:00It seems like if you have a very large collection ...It seems like if you have a very large collection then the @sort formula became to large and faile.<BR/><BR/>Im in a hurry (at a customer) so I dont have the time to investigate it further. So this is just to let You knowAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-26775512.post-1150360140783722732006-06-15T10:29:00.000+02:002006-06-15T10:29:00.000+02:00Thanks, I was not aware of this problem.I haven't ...Thanks, I was not aware of this problem.<BR/>I haven't had a chance to test or even try to reproduce, but this is the first idea for a workaround that comes to mind:<BR/>1) Replace all quotes with a string that is not likely to appear elsewhere in the data, e.g. #maxquotestring#<BR/>2) Run SortCollection<BR/>3) Re-replace that string with the quotes again.<BR/><BR/>I will try to revisit this again later and will post any improvements to the function.Max Flodénhttp://www.blogger.com/profile/14422190564367108454noreply@blogger.comtag:blogger.com,1999:blog-26775512.post-1150228887009101822006-06-13T22:01:00.000+02:002006-06-13T22:01:00.000+02:00Great function for sorting collections.I did find ...Great function for sorting collections.<BR/><BR/>I did find a problem, the sort fails if data to be sorted contains quotes. It makes @sort function an invalid formula. <BR/><BR/>I am trying to devise a workaround but no success yet.<BR/><BR/>Any Ideas?Stevenoreply@blogger.com