The following example uses dir( ) to store the file information for all the files in the current directory to the array aFiles. Then the array is sorted on the file size. Manifest constants to represent the columns are created with the #define preprocessor directive to make the code more readable.

#define ARRAY_DIR_NAME 1 // Manifest constants for columns returned by dir( )

#define ARRAY_DIR_SIZE 2

#define ARRAY_DIR_DATE 3

#define ARRAY_DIR_TIME 4

#define ARRAY_DIR_ATTR 5

aFiles = new Array( )

nFiles = aFiles.dir( )

aFiles.sort( ARRAY_DIR_SIZE ) // Sort by size

for nFile = 1 to nFiles

   ? aFiles[ nFile, ARRAY_DIR_NAME ] 

   ?? aFiles[ nFile, ARRAY_DIR_SIZE ] at 25 

endfor