## $ORDER## 1995 Version of ANSI (Equivalent to Current ISO Version) of Standard |

This form returns a value which is a subscript according to a subscript ordering sequence. This ordering sequence is specified below with the aid of a function, CO, which is used for definitional purposes only, to establish the collating sequence.

CO(*s*,*t*) is defined, for strings *s* and
*t*, as follows:

- When
*t*follows*s*in the ordering sequence or if*s*is the empty string, CO(*s*,*t*) returns*t*. - Otherwise, CO(
*s*,*t*) returns*s*.

The ordering sequence is defined using the *collation
algorithm* determined as follows:

- If $Order refers to a
__gvn__with name*global*then the value of $Get(^$Global("*global"*,"COLLATE")) determines the algorithm. - If $Order does not refer to a
__gvn__, then the value of $Get(^$Character(^$Job($Job,"CHARACTER"),"COLLATE")) determines the algorithm. - If the resulting algorithm is the empty string, then the
*collation algorithm*of the__charset__M defined in Annex A is used.

The collation value *order* of a string *subscript*
using a collation algorithm *collate* may be determined by
executing the expression
("S *order*="_*collate*_"(*subscript*)"). Two
collation values are compared on a character-by-character basis
using the $ASCII values (i.e. equivalent to the follows (])
operator).

Only subscripted forms of __glvn__ are permitted. Let
__glvn__ be of the form NAME(*s*_{1},
*s*_{2}, ..., *s*_{n}) where
*s*_{n} may be the empty string. Let *A* be the
set of subscripts that follow *s*_{n}. That is, for
all *s* in *A*:

- CO(
*s*_{n},*s*) =*s*and - $D(NAME(
*s*_{1},*s*_{2}, ...,*s*_{n–1},*s*)) is not zero.

Then $Order(NAME(*s*_{1},
*s*_{2}, ..., *s*_{n})) returns that
value *t* in *A* such that CO(*t*,*s*) =
*s* for all *s* not equal to *t*; that is, all
other subscripts which follow *s*_{n} also follow
*t*.

If no such *t* exists, $Order returns the empty
string.

Let S be the value of __expr__. Then
$Order(__glvn__,__expr__) returns:

- If S = 1, the function returns a result identical to
that returned by $Order(
__glvn__). If S = –1, the function returns a value which is a subscript, according to a subscript ordering sequence. This ordering sequence is specified below with the aid of a functions CO and CP, which are used for definitional purposes only, to establish the collating sequence.

CO(

*s*,*t*) is defined, for strings*s*and*t*, according to the*collation algorithm*of the specific__charset__.CP(

*s*,*t*) is defined, for strings*s*and*t*, as follows:When

*t*follows*s*in the ordering sequence and*s*is not the empty string, CP(*s*,*t*) returns*s*.

Otherwise, CP(*s*,*t*) returns*t*.The following cases define the ordering sequence for CP:

- CP("",
*t*) =*t*. - CP(
*s*,*t*) =*t*if CO(*s*,*t*) =*s*; otherwise, CP(*s*,*t*) =*s*.

Only subscripted forms of

__glvn__are permitted. Let__glvn__be of the form NAME(*s*_{1},*s*_{2}, ...,*s*_{n}) where*s*_{n}may be the empty string. Let A be the set of subscripts that precede*s*_{n}. That is, for all*s*in A:- CP(
*s*_{n},*s*) =*s*and - $D(NAME(
*s*_{1},*s*_{2}, ...,*s*_{n–1},*s*)) is not zero.

Then $Order(NAME(

*s*_{1},*s*_{2}, ...,*s*_{n}), –1) returns that value*t*in A such that CP(*t*,*s*) =*t*for all*s*not equal to*t*; that is, all other subscripts which precede*s*also precede*t*.If no such

*t*exists, $Order(NAME(*s*_{1},*s*_{2}, ...,*s*_{n}), –1) returns the empty string.- CP("",
- Values of S other than 1 and –1 are reserved for future extensions of the $Order function.

Copyright © Standard Documents; 1977-2018 MUMPS Development Committee;

Copyright © Examples: 1995-2018 Ed de Moel;

Copyright © Annotations: 2003-2008 Jacquard Systems Research

Copyright © Annotations: 2008-2018 Ed de Moel.

This page most recently updated on 13-Sep-2014, 16:55:44 .

For comments, contact Ed de Moel (demoel@jacquardsystems.com)