Sorting a document collection

Hello forum!

I have built a wabsearch-agent whitch searches documents in a database and prints them out. But my problem is to sort them, because the users must have some sortoptions.

To do this i have built a workaraound for sorting the collection. But this workaraound is very slowly, so the response-time for users (with browsers) is very high.

Does anyone have a faster workaraound to sort a document collection? Or can anyone tell me, why this sorting is so slowly? This is the code (works ONLY with sorted collections!)

Dim doc As NotesDocument

Dim docSelected As NotesDocument

Dim i,j,k As Long



Set doc = coll.GetFirstDocument



j = coll.Count

For k=1 To coll.Count

	

	For i=1 To j

		If i=1 Then

			Set docSelected = doc

		Elseif Clng(doc.fldPrice(0)) < Clng(docSelected.fldPrice(0)) Then

			Set docSelected = doc				

		End If

		Set doc = coll.GetNextDocument(doc)

	Next i

	

	Call coll.DeleteDocument(docSelected)

	Call coll.addDocument(docSelected)

	Set doc = coll.GetFirstDocument

	j = j - 1

Next k

Another optionis, to take the ftsearch method from a sorted view, but then i must delete the ft-index to have a sorted result…

Thank you for any answers!

Bernd

Subject: Sorting a document collection

Articles on sorting Document Collection -

http://www.tjitjing.com/blog/2006/05/how-to-sort-notesdocumentcollection-in.html

http://www.notes411.com/dominosource/faq.nsf/0/6AA9F702B045D61D80256D6E007AC1D4!OpenDocument

http://www.notestips.com/80256B3A007F2692/1/TAIO6NLGKJ

–Phani

Subject: RE: Sorting a document collection

Thank You for the Links!

The blog entry on http://www.tjitjing.com works perfectly!