sort

Table of Contents

Overview

The sort function sorts the elements, or key value pairs based on values in a collection.

Syntax

<collectionVariable>.sort(<booleanValue>);

where,

ParameterData typeDescription
<collectionVariable>COLLECTION

The variable in which elements or key value pairs will be sorted.

<booleanValue>

(optional)

BOOLEAN

Applicable values are true and false.

The value true sorts in ascending(default) order, and the value false sorts in descending order.

In a string list, special characters, upper case, and lower case letters are sorted in the following order:
! " # $ % & ' ( ) * + , - . / <numerical values> : ; < = > ? @ <capital letters> [ ] ^ _ ` <small letters> { | } ~

Examples

 productVersion1=collection("Creator":5,"CRM":2,"Mail":8);
 productVersion1.sort();// collection becomes {"CRM":2,"Creator":5,"Mail":8}
 productVersion2=collection("Creator","CRM","Mail");
 productVersion2.sort(false);// collection becomes {"Mail", "Creator", "CRM"}