SORT# returns a string containing a sorted Telitab set

Syntax

SORT#(Telitab$, SortPar$, [Mode%=0 or 1])

Arguments 

  • Telitab$ is a string expression containing/returning a Telitab set.
  • SortPar$ is a name of parameter for which the Telitab$ will be unfolded and subsequently sorted.
  • Mode% is a optional sort modus:
    • Mode%=0, will sort cases for SortPar$ values from low to high (ascending).
    • Mode%=1, will sort cases for SortPar$ values from high to low (descending).

Examples

Before explaining the SORT# function, some words on unfolding a Telitab set for a particular parameter. Unfolding implies that the record(s) containing this parameter are moved to the top of the hierarchy.

So if Telitab_1$ contains the dataset:


"MODELS" 


-4 "1" "2" "3" "4" 
"MODMAT$" "wood" "foam" "wood" "plywood" 
"LPP" 112.30 133.80 98.60 145.00 
"B" 17.80 21.50 16.42 22.40 
"T" 7.65 9.20 6.70 9.40 

"PROJECTS" 


"CLIENT$" "YardX" 
}

To explain the data: 
you have two objects, MODELS and PROJECTS presented as list values in Telitab_1$ containing TeLiTabs themselfs (with several parameters). 
LPP is part of the MODELS object (TeLiTab).

When you unfold Telitab_1$ dataset on parameter "LPP", you get:


"PROJECTS" 


"CLIENT$" "YardX" 


-4 "1" "2" "3" "4" 
"MODMAT$" "wood" "foam" "wood" "plywood" 
"LPP" 112.30 133.80 98.60 145.00 
"B" 17.80 21.50 16.42 22.40 
"T" 7.65 9.20 6.70 9.40

You see that PROJECT still is a separate object (and presented as a list value in Telitab_1$). All other data (which was part of the MODELS object) now is part of Telitab_1$ and thus a table in the TeLiTab.

To unfold a Telitab set for a particular parameter implies that the record(s) containing this parameter are moved to the top of the hierarchy. If UnfoldPar$ = "NullString", no unfolding is performed.

The SORT#() function unfolds and sorts de telitab like in the following example:

SORT#(Telitab_1$, "LPP", 0) 

or 

SORT#(Telitab_1$, "LPP")) 

returns:


"PROJECTS" 


"CLIENT$" "YardX" 

-4 "1" "2" "3" "4" 
"MODMAT$" "wood" "wood" "foam" "plywood" 
"LPP" 98.60 112.30 133.80 145.00 
"B" 16.42 17.80 21.50 22.40 
"T" 6.70 7.65 9.20 9.40


SORT#(Telitab_1$, "LPP", 1)

 returns:


"PROJECTS" 


"CLIENT$" "YardX" 

-4 "1" "2" "3" "4" 
"MODMAT$" "plywood" "foam" "wood" "wood" 
"LPP" 145.00 133.80 112.30 98.60 
"B" 22.40 21.50 17.80 16.42 
"T" 9.40 9.20 7.65 6.70

 

If SortPar$ contains a parameter which does not occurr in the Telitab$ set, an error message is returned:

"No valid Sort parameter: "ParName" given in SORT# function."


 

Quick links: Functions overview | Attribute overview | Constants overview | Dimensions overview


  • No labels