Sort Method

Sort Method

         Example         Applies To

Sorts the collection of items by the specified property. The index for the collection is reset to 1 upon completion of this method.

For Items:

Syntax 1

objItems.Sort(Property, [Descending])

objItems   Required. An expression that returns an Items collection object.

Property   Required String. The name of the property by which to sort, which may be enclosed in brackets (for example, "[CompanyName]"). May not be a user-defined field, and may not be a multi-valued property, such as a category.

Descending   Optional Boolean. True to sort in descending order. The default value is False (ascending).

For the AddressEntries collection:

Syntax 2

obAddressEntries.Sort([Property], [Descending])

objAddressEntries   Required. An expression that returns an AddressEntries collection object.

Property   Optional String. The name of the property by which to sort, which may be enclosed in brackets (for example, "[Name]").

Descending   Optional Long. Can be one of the OlSortOrder constants:

olAscending(1), olDescending(2), or olSortNone(0).

Remarks

For the Items collection, Sort cannot be used, and will cause an error, with the following properties:

Categories

Children

Class

Companies

CompanyLastFirstNoSpace

CompanyLastFirstSpaceOnly

Contacts

DLName

IsOnlineMeeting

LastFirstAndSuffix

LastFirstNoSpace

LastFirstNoSpaceCompany

LastFirstSpaceOnly

LastFirstSpaceOnlyCompany

MemberCount

NetMeetingAlias

NetMeetingAutoStart

NetMeetingOrganizerAlias

NetMeetingServer

NetMeetingType

RecurrenceState

ResponseState

Saved


Sort only affects the order of items in a collection. It does not affect the order of items in an explorer view.