sort()
Table of Contents
Overview
The sort() function takes listVariable and booleanValue as arguments.
It returns the list with its elements sorted in:
- ascending order if the specified boolean value is true.
- ascending order if the boolean value is not specified.
- descending order if the specified boolean value is false.
While sorting string characters, the function will first check the letter case, and then the actual letter.
In a text list, special characters, upper case, and lower case letters are sorted in the following order:
! " # $ % & ' ( ) * + , - . / : ; < = > ? @ <capital letters> [ ] ^ _ ` <small letters> { | } ~
Return Type
- List
Syntax
Parameter | Description | Data type |
---|---|---|
<variable> (optional) | Variable which will contain the returned list. | LIST |
<listVariable> | The list variable whose elements will be sorted. If the list contains elements of different data types, the function will return null. | LIST |
<booleanValue> (optional) | Applicable values are: true or false. | BOOLEAN |
Examples
sortOrder = listVar.sort(true); //returns {"Creator", "Zoho Creator", "crm"}
The return order in the above example is "Creator", followed by "Zoho Creator", followed by CRM. This is because, as specified in the 'note' above, text elements with capital letters are sorted first, and then the lower case letters.