Application.Sort Method (Project)

Sorts the tasks or resources in the active pane.

Syntax

expression. Sort( _Key1_, _Ascending1_, _Key2_, _Ascending2_, _Key3_, _Ascending3_, _Renumber_, _Outline_ )

expression A variable that represents an Application object.

Parameters

Name Required/Optional Data type Description
Key1 Optional String The name of a primary field to sort. If Key1 is omitted, Project displays the Sort dialog box.
Ascending1 Optional Boolean True if the primary field will be sorted in ascending order. The default value is True.
Key2 Optional String The name of a secondary field to sort.
Ascending2 Optional Boolean True if the secondary field will be sorted in ascending order. The default value is True.
Key3 Optional String The name of a tertiary field to sort.
Ascending3 Optional Boolean True if the tertiary field will be sorted in ascending order. The default value is True.
Renumber Optional Boolean True if Project renumbers tasks after sorting them. For task views, Renumber can be True only if Outline is True. If Outline is True, then Renumber defaults to the current setting in the Sort dialog box. If Outline is False, Renumber is ignored.
Outline Optional Boolean True if the outline level of tasks or resources will be preserved after sorting them. The default value is True.

Return value

Boolean

Example

The following example sorts the tasks in the active project by priority, and then renumbers the tasks.

Sub SortByPriority() 
 Sort Key1:="Priority", Ascending1:=True, Renumber:=True 
End Sub