?
Solved

Sorting a collection

Posted on 2003-04-01
2
Medium Priority
?
288 Views
Last Modified: 2013-12-18
does anyone know how I can sort a document collection and use the results of the sort?
Pleeeeaaaassssee help
0
Comment
Question by:Cuec
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
Jean Marie Geeraerts earned 200 total points
ID: 8245122
Easiest way is to create a folder, define the sorting order in the folder.
Put the collection in the folder with .PutAllInFolder method.
Then read first document from the folder and iterate through the folder using view methods.

A little bit of sample script:

Sub Initialize
   dim session as NotesSession
   dim db as NotesDatabase
   dim coll as NotesDocumentCollection
   dim folder as NotesView

   set db=session.CurrentDatabase
   set coll=db.UnprocessedDocuments
   rem Put the collection in a sorted folder, set sort options in the folder
   call coll.PutAllInFolder("SortedFolder")
   rem Get a reference to the folder
   set folder=db.GetView("SortedFolder")
   rem walk through the documents in the folder one by one
   dim doc as NotesDocument
   set doc=folder.GetFirstDocument
   do while not doc is nothing
      rem Process document and then get next document
      set doc=folder.GetNextDocument(doc)
   loop
End Sub

Hope this gets you on your way, if not just ask for further info.

Regards,
JM
0
 

Expert Comment

by:tritanka
ID: 8276308
As a second option, put all the docs in an array of type NotesDocument then use a quicksort algorithm to sort the array.

This really depends on how many documents you are talking about.

Jerrith's solution seems more elegant and will probably result in less over the wire traffic when working with a server based database.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question