Summary
##########################################################################
File: sort.icn
Subject: Procedures for sorting
Authors: Bob Alexander, Richard L. Goerwitz, and Ralph E. Griswold
Date: September 10, 1998
###########################################################################
This file is in the public domain.
###########################################################################
isort(x, p)
customized sort in which procedure p is used for
comparison.
sortff(L, fields[])
like sortf(), except takes an unlimited number of field
arguments.
sortgen(T, m)
generates sorted output in a manner specified by m:
"k+" sort by key in ascending order
"k-" sort by key in descending order
"v+" sort by value in ascending order
"v-" sort by value in descending order
sortt(T, i)
like sort(T, i) but produces a list of two-element records
instead of a list of two-element lists.
###########################################################################
Customizable sort procedure for inclusion in Icon programs.
isort(x,keyproc,y)
Argument x can be any Icon data type that is divisible into elements
by the unary element generation (!) operator. The result is a list
of the objects in sorted order.
The default is to sort elements in their natural, Icon-defined order.
However, an optional parameter (keyproc) allows a sort key to be
derived from each element, rather than the default of using the
element itself as the key. Keyproc can be a procedure provided by
the caller, in which case the first argument to the key procedure is
the item for which the key is to be computed, and the second argument
is isort's argument y, passed unchanged. The keyproc must produce
the extracted key. Alternatively, the keyproc argument can be an
integer, in which case it specifies a subscript to be applied to each
item to produce a key. Keyproc will be called once for each element
of structure x.
###########################################################################
Procedures:
isort, sortff, sortff_1, sortgen, sortt
Records:
element
This file is part of the (main) package.
Source code.
isort(x, keyproc, y)
sortff(L, fields)
: sort on multiple fields
sortff_1(L, fields, k, uniqueObject)
sortgen(T, m)
: generate by different sorting orders
sortt(T, i)
: sort to produce list of records
element(key, value)
This page produced by UniDoc on 2021/04/15 @ 23:59:54.