Please enable JavaScript to view this site.

thinBasic Help Manual

* * HELP & MANUAL PREMIUM PACK 4 DEMO VERSION * *

This documentation was styled with a demo skin from the Premium Pack 4 add-on for Help & Manual. The contents of the skin are encrypted and not configurable. You can only publish HM projects with this skin. You cannot edit it or change it.

This version is copyright and may only be used for local testing purposes. It may not be distributed.

Please purchase the full version of the Premium Pack to get the configurable skins and remove this notice. The package will also include the Toolbox configuration utility for Premium Pack skins.

 

Description

 

Sort an array or part of the array.

 

Syntax

 

ARRAY SORT ArrayVariable([StartIndex]) [FOR nElements] [, COLLATE UCASE] [, {ASCEND | DESCEND}] [, ASFILES]

 

Returns

 

None

 

Parameters

 

Name

Type

Optional

Meaning

ArrayVariable


No

Name of a declared and already dimensioned array.

StartIndex

Number

Yes

The element index inside the array from which to start. If omitted, 1 is assumed

nElements

Number

Yes

Number of elements to sort starting from StartIndex. If omitted, end of the array is assumed.

 

Remarks

 

ASFILES is a special clause used to sort kind of file names string using the so called "natural sorting" comparison.

This clause can be used when sorting files whose names contains a sort of patter composed by name + number + extension. Each Array element is decomposed in the single part of the patter (Name, Number, Extension) and adapted to be sorted.

No modifications will take place to the original array elements.

 

Example:

Picture1.jpg

Picture2.jpg

Picture3.jpg

Picture4.jpg

Picture5.jpg

Picture6.jpg

Picture7.jpg

Picture8.jpg

Picture9.jpg

Picture10.jpg

Picture11.jpg

Picture12.jpg

 

A standard order would sort the above list in the following way

While using ASFILES it will sort considering the numeric part be a number

Picture1.jpg

Picture10.jpg

Picture11.jpg

Picture12.jpg

Picture2.jpg

Picture3.jpg

Picture4.jpg

Picture5.jpg

Picture6.jpg

Picture7.jpg

Picture8.jpg

Picture9.jpg

Picture1.jpg

Picture2.jpg

Picture3.jpg

Picture4.jpg

Picture5.jpg

Picture6.jpg

Picture7.jpg

Picture8.jpg

Picture9.jpg

Picture10.jpg

Picture11.jpg

Picture12.jpg

 

ASFILES also compares string length for optimum comparison.

 

Restrictions

 

ASFILES clause can sort strings up to 255 chars maximum file lenght

 

See also

 

LBound, UBound, ARRAY ASSIGN,

 

Examples

 

 

 

 

Created with Help+Manual 8 and styled with Premium Pack Version 4 © by EC Software