list class : Sort(bool) method

Description

Gets a new list is sorted.

Syntax

listInstance.Sort(bool order)

Arguments

ClassNameDescription
boolorderSort order.

Return value

ClassDescription
sorted listA new list that is sorted.

Sample code

1:

list{int} intList = new list{int}();

2:

intList.Add(3);

3:

intList.Add(2);

4:

intList.Add(1);

5:

list{int} newList = intList.Sort(true); // Order of the returned list will be 1, 2, 3.

Notes

This method is added in Ver 1.1.0.0.

If the argument is true, the returned list is sorted in ascending order. Otherwise, it is sorted in descending order.

Returns a new list that is sorted. The order of the caller list does not change.

The returned list is a shallow copy of the caller list.

It will throw an exception (RtypeException) if you call this method on lists other than list{int}, list{long}, list{real}, list{bool}, or list{string}.

Links for reference

None

Copyright © Rice All rights reserved.