summaryrefslogtreecommitdiff
path: root/ipl/procs/sortt.icn
blob: a46b20e1af6ed08809e644d7db3bd2bd71130021 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
############################################################################
#
#	File:     sortt.icn
#
#	Subject:  Procedure to sort table into records
#
#	Author:   Ralph E. Griswold
#
#	Date:     August 20, 1998
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
#  This program sorts a table in the manner of sort(T, i) but produces a
#  list of two-element records instead of a list of two-element lists
#
############################################################################
#
#  Requires:  Version 9
#
############################################################################

record element(key, value)

procedure sortt(T, i)
   local result, k

   if not(integer(i) = (1 | 2)) then runerr(205, i)

   result := []

   every put(result, element(k := key(T), T[k]))

   return sortf(result, i)

end