SORTA

Contents


Sorta is used to sort tables of single-dimensioned variables.

 

Syntax

   Sorta [ rep ] list_nom_var [ Order By list_expr ]

 

Parameters

Element

Description

Restrictions

rep

Integer numerical expression of the number of elements to be sorted. By default, this is the number of elements of the first table in the list.

rep must not exceed the number of elements of the smallest table.

list_nom_var

List ofnom_var separated by the character ','.

None.

nom_var

nom_de_variable indicating the table on which the sort is performed. For a scrolling table, this is the variable for the foot of the table.

None.

list_expr

List of expr separated by the character ','.

None.

expr

Date type expression.

None.

 

Examples

   # Sort on elements of a scrolling table by name then by first name.
   # NLI is the bottom of table variable name, containing therefore
   # the number of elements of the table.
   
   Sorta NLI NLI Order By NOM([S]indice), PRENOM([S]indice)

   # There are 3 tables of elements NUM, CAR and NOM taken from a set of
   # texts. NUM is a table of integers (text numbers),

   # CAR a table of characters (associated with the texts) and
   # NOM a table of character strings (titles):

NUM

1

2

3

4

5

6

CAR

A

H

I

V

V

A

NOM

at386

hp

ibm3151

vt220

vt200

ansi (1)

 

   # Sort on 3 tables in order of characters, then on the match between 2
   # characters in the order of the texts then on NUM values
    Sorta CAR, NOM, NUM

   # The sort result is as follows:

NUM

6

1

2

3

5

4

CAR

A

A

H

I

V

V

NOM

ansi

at386

hp

ibm3151

vt200

vt220

 

   # Starting from position (1), sort the 3 tables in the order
   # of the characters
    Sorta CAR, NOM, NUM Order By CAR(indice)

   # The sort result is as follows (for example, since the order of
   # values for the NUM and NOM tables for the indices 0 and 1 on the one hand,
   # 4 and 5 on the other may be different, since the sort is non-conservative

NUM

1

6

2

3

4

5

CAR

A

A

H

I

V

V

NOM

at386

ansi

hp

ibm3151

vt220

vt200

 

Description and comments

The instruction Sorta is used to sort elements of tables with one dimension. If the number of elements to be sorted is not specified, the sort must be performed on all the elements of the tables.

The sort is ascending.

When there is no Order By clause, the sort is performed in the order of the first table. If elements in this table are equal, it will be performed in the order of the second table, and so on for all the tables to be sorted.

If a sequence is given (the expressions being constructed from the index system variable) the sort takes place according to the value of the first expression, then if there is a match, according to the value of the second, and so on for the others.

For a scrolling table, the number of elements to be sorted must be specified, as well as the sort order. On the other hand, the variable name given is that of the variable for the foot of the table; it then indicates all the variables in the scrolling table.

We should state that the sort is non-conservative. This means that if elements in a table are the same, it is not possible to know in which order these equal elements will appear in the result for the other tables (unless there are other criteria).

 

Comment

Tables with different numbers of elements may be sorted. In this case a value must be given to the rep parameter at least equal to the smallest of the tables.

 

Associated errors

Error

Description

ERMODE (10)

rep is not numerical.

ERINDI ( 8)

Incorrect index.

ERDOM (50)

rep < 0.

 

Associated key words

INSA - DELA


CONTENTS


Copyright © Sage 1999 - 2007