The Sort built-in extract file method orders records in the extract file. The sort order applied is specified by the Key built-in method.
The extract file must be named and its layout defined before the Sort method is invoked. An extract file can be named using an Extract, Determine Actual, or SetTitle logic statement. The layout can be defined using an Extract, Determine Actual, or Match logic statement.
The extract file should be opened before the Sort method is invoked. Refer to Open for more information on opening extract files.
Failure behavior
If the extract file is not successfully sorted, the Sort method sets the Glb.Status built-in segment attribute to "*****".
Restrictions
Business Information Server Extract files cannot be sorted using the the Sort method.
Syntax
<<extractFile>>::Sort(sortOn : sortOrder) : void
Owner
Any extract file.
Parameters
sortOn
A Key built-in method invocation that specifies the sort order.
Examples
Example 1
In this example, extract file FileA is sorted into ascending order of Input_Date within ascending order of Product.
Determine Actual CustSale Extract Event As FileA End FileA.Sort(Key(FileA.Event.Product, "Ascending"), Key(FileA.Event.Input_Date, "Ascending")) Determine Actual FileA : Logic End
Example 2
In this example, extract file FileA is sorted into into order of Address within descending order of Branch, within descending order of Company.
FileA.Sort(Key(FileA.Company, "Descending"),\ Key(FileA.Branch, "Descending"),\ Key(FileA.Address, "Ascending")) Determine Actual FileA
Example 3
In this example, an existing extract file FileA is named, sorted, and then read as the sorted file. The "dummy" Extract logic statement is never executed, but is required to provide the layout of the extract file.
DoWhen SD_A != "FileA" Extract Event As FileA : Defines layout of the file End SetTitle FileA "SD_A_File" Exist : Names the file FileA.Sort(Key(FileA.Event.Product, "Ascending"),\ Key(FileA.Event.Input_Date. "Ascending")) : Sorts the file Determine Actual FileA : Reads the sorted file : Logic End;