os.Path.dirsort

The os.Path.dirsort method defines the sort criteria and sort order for the opened directory. The syntax of the function is as follows:

CALL os.Path.dirsort(criteria, order)

 

where:

·         criteria = a variable of STRING data type standing for the sort criteria. This parameter must be defined by one of the following strings:

 

undefined = means that no sort criteria is set which is the default. In this case all the entries are read as returned by the os.Path methods,

name, size, extension or type  = sorts the directory by file name, size, extension or type (directory, link, regular file) respectively,

atime = sorts the directory by access time,

mtime = sorts the directory by modification time;

·         order = a variable of INTEGER data type which specifies whether the sort order is ascending or descending:

 

1 = defines the ascending order,

-1 = defines the descending order.

 

Usage

 

By this function invocation, the sort criteria and sort order are defined for any subsequent diropen call.

When using the sort criteria "name", the directory entries are ordered with regard to the current locale. When sorting by any other criteria, entries of the same value for the defined criteria are sorted by name following the value of the order parameter.

 

Here is an example of the os.Path.dirsort method calling:

 

#sort by name, ascending

CALL os.Path.dirsort("name", 1)