Category:ALGOL 68-sort

From Rosetta Code
Library
This is an example of a library. You may see a list of other libraries used on Rosetta Code at Category:Solutions by Library.

ALGOL 68-sort is a set of sorting related modes and operators for use in ALGOL 68 programs.

To use this in a program, copy the source code from the Talk page to a text file called sort.incl.a68, putting it in the same directory as the importing program.
Then add PR read "sort.incl.a68" PR to the source of the program.

If you are using ALGOL 68G or another compiler/interpreter that supports the read pragmatic comment, then the program can be run as usual.
For other compilers, the ALGOL 68 pre-processor in Compiler/Simple file inclusion pre processor#ALGOL 68 can be used (see the instructions on that page).


Modes

The following modes are defined in this library:

  • MODE ELEMENTS = STRUCT( INT low, high )
Defines the bounds of a sub-array to sort.

Operators

The following operators are defined in this library:

  • OP (REF INT,REF INT)REF INT =:=
  • OP (REF REAL,REF REAL)REF REAL =:=
  • OP (REF STRING,REF STRING)REF STRING =:=
Swaps the values of its parameters.
  • OP (REF[]INT)REF[]INT QUICKSORT
  • OP (REF[]REAL)REF[]REAL QUICKSORT
  • OP (REF[]STRING)REF[]STRING QUICKSORT
Quicksorts in-place the specified row.
  • OP (REF[]INT,ELEMENTS)REF[]INT QUICKSORT
  • OP (REF[]REAL,ELEMENTS)REF[]REAL QUICKSORT
  • OP (REF[]STRING,ELEMENTS)REF[]STRING QUICKSORT
Quicksorts in-place the elements of the specified row specified by low and high of the ELEMENTS parameter.