Sorts the elements found in a memory List Box, ListView or Combo Box control. This function has no effect on the browsing List Box, ListView and Combo Box controls.

Note: This function is useless if the control was declared as "Sorted" in the description window of control ("Details" tab).

Versions 16 and later

This function is now available for WINDEV applications in Linux.

New in version 16

This function is now available for WINDEV applications in Linux.

This function is now available for WINDEV applications in Linux.

Versions 17 and later

This function is now available for iPhone/iPad applications.

New in version 17

This function is now available for iPhone/iPad applications.

This function is now available for iPhone/iPad applications.

Versions 18 and later

This function is now available in Windows Store apps mode.

New in version 18

This function is now available in Windows Store apps mode.

This function is now available in Windows Store apps mode.

Versions 21 and later

This function is now available in Universal Windows 10 App mode.

New in version 21

This function is now available in Universal Windows 10 App mode.

This function is now available in Universal Windows 10 App mode.

Example

// Sorts the List Box control in lexicographical order LIST_Customer.Sort(True, ccLexicographicOrder)

True (by default) to perform a sort in ascending order,

False to perform a sort in descending order.

<Sort options>: Optional constant (or combination of constants)

Sort options selected for the content of List Box (or Combo Box) control:

ccLexicographicOrder

Sort the character strings in lexicographical order (for example, the 'é' character is found between the 'e' and 'f' characters).

ccNormal

Sort while performing a standard comparison, similar to the = operator =.

ccRespectNumeric

Sort while taking into account the numeric values inside the strings (in this case, "10" comes after "9").

ccIgnoreAccent

Sort while ignoring the accented characters

ccIgnoreCase

Sort while ignoring the case (uppercase/lowercase characters).

ccIgnoreSpace

Sort while ignoring the space characters found before and after the character strings.

ccIgnorePunctuationAndSpace

Sort while ignoring the punctuation and the space characters (see the Notes for more details)

sortDefault (default value)

Sort while ignoring the case and the accented characters and while taking the space characters into account.

sortWithoutFunctionGxxx

Sort while ignoring the elements such as gImage, gLink, ... By default, these elements are taken into account by the sort.

Remarks

Effect of the function <List Box>.Sort

<List Box>.Sort has a one-off effect: the elements added to the List Box or to the Combo Box control once <List Box>.Sort has been used will comply with the sort options defined in the description window of control.

Comparing the numeric values

The ccRespectNumeric constant performs the sort by taking into account the numeric value represented by digits and not just the alphabetical order of numbers.

Without the ccRespectNumeric constant, the strings below will be sorted in the following order: "string1", "string10", "string2"

With the ccRespectNumeric constant, the same strings will be sorted in this order: "string1", "string2", "string10"

Lets' see some examples of comparison performed with and without the ccRespectNumeric constant:

Sorting strings containing digits without the ccRespectNumeric constant

Sorting strings containing digits with the ccRespectNumeric constant

0

00

00

0

001

001

009

01

01

1

010

009

09

09

1

9

10

010

11

10

9

11

Sorting strings containing digits without the ccRespectNumeric constant

Sorting strings containing digits with the ccRespectNumeric constant

10.00Aa

7.00Aa

10.01Gh

7.01Ba

10.50Ag

7.01Dfe

11.00Aa

7.50Fg

7.00Aa

7.51Tga

7.01Ba

8.00Aa

7.01Dfe

8.01Gjk

7.50Fg

8.01Ty

7.51Tga

8.50Ze

8.00Aa

9.00Aa

8.01Gjk

9.80Er

8.01Ty

9.99Zaaa

8.50Ze

10.00Aa

9.00Aa

10.01Gh

9.80Er

10.50Ag

9.99Zaaa

11.00Aa

Characters taken into account for the punctuation and the spaces

The characters taken into account for the punctuation and the spaces are supplied by the system. To get the list of these characters, write the following WLanguage code:

s is string FOR i = 0 TO 255 IF Charact(i) <> StringFormat(Charact(i), ccIgnorePunctuationAndSpace) THEN s += Charact(i) END END Info(s) ToClipboard(s)