os.Path.dirSort

Defines the sort criteria and sort order for os.Path.dirOpen().

Syntax

os.Path.dirSort(
   criteria STRING,
   order INTEGER )
  1. criteria is the sort criteria.
  2. order defines ascending (1) or descending (-1) order.

Usage

When you call this function, you define the sort criteria and sort order for any subsequent os.Path.dirOpen() call.

The criteria parameter must be one of the following strings:

  • "undefined" = No sort. This is the default. Entries are read as returned by the OS functions.
  • "name" = Sort by file name.
  • "size" = Sort by file size.
  • "type" = Sort by file type (directory, link, regular file).
  • "atime" = Sort by access time.
  • "mtime" = Sort by modification time.
  • "extension" = Sort by file extension.

When sorting by name, directory entries will be ordered base on the current locale.

When sorting by any criteria other than the file name, entries having the same value for the given criteria are ordered by name following the value of the order parameter.