Previous Page Next Page Contents

numeric::sort -- sort a numerical list

Introduction

numeric::sort(list) sorts the elements in list.

Call(s)

numeric::sort(list)

Parameters

list - a list of numbers or numerical expressions

Returns

a sorted list

Side Effects

The function is sensitive to the environment variable DIGITS.

Related Functions

sort

Details

Example 1

>> numeric::sort([1, 2.0, I, -3, -I, PI, sqrt(2)])
        [-3.0, 1.0 I, - 1.0 I, 1.0, 1.414213562, 2.0, 3.141592654]

In the following example the sorting criterion does not seem to be satisfied:

>> x := sin(PI/3):
>> L := numeric::sort([x, sin(float(PI/3)) - I, x + I])
        [0.8660254038 - 1.0 I, 0.8660254038, 0.8660254038 + 1.0 I]

This is explained by the fact that the floating point numbers internally have a more accurate representation than shown on the screen. The real part of the first element is indeed a little bit smaller than the other real parts:

>> DIGITS := 20: L
      [0.86602540378443864668 - 1.0 I, 0.86602540378443864673,
      
         0.86602540378443864673 + 1.0 I]
>> delete x, L, DIGITS:

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000