SORT Command

The SORT command produces a sorted and formatted report which can be displayed on the screen or sent to the printer. SORT produces a display almost identical to that of the LIST command, except in sorted order.

Format

SORT [DICT] filename [item-list] [selection] [sort-keys] [output] [print] [modifiers] [(options)]

Parameter(s)

DICT

Specifies the file dictionary.

filename

Name of the file.

item-list

List of individual item-IDs. Enclose each item-ID in single quotes. The system sorts these items in the order that you specify with sort-keys.

selection

Specifies one or more conditions that an item must meet to be included in the report. For a complete description of selection expression syntax, see the LIST Command.

sort-keys

Specify which attributes to sort and whether to sort them in ascending or descending order. You can use the following modifiers with sort-keys:

BY

Sorts items in ascending order by the specified attribute.

BY-DSND

Sorts items in descending order by the specified attribute.

BY-EXP

Sorts a MultiValued attribute in ascending order and produces a separate line for each value.

BY-EXP-DSND

Sorts a MultiValued attribute in descending order and produces a separate line for each value.

If more than one sort-key is specified in a SORT command line, the system sorts these attributes from left to right (the leftmost sort-key is the most significant).

output

Those attributes to be included in the report. By default, the SORT command displays only item-IDs. output can also be a user-defined phrase that contains any INFO/ACCESS parameters except a command or file name.

print

Specifies which values from MultiValued attributes are to be included in the report. Use relational operators and values (enclosed in double quotes or backslashes) immediately following the name of the MultiValued attribute.

modifiers

Include one or more keywords that specify the format of the report. These parameters affect headers, footers, spacing, totalling column figures, control breaks, and more. For complete information about using these keywords, see the section, Connectives, Modifiers, and Options in the INFO/ACCESS User Reference Guide.

options

Include one or more single-character codes that specify the report format and direct or modify output. They must be enclosed in parentheses, can be entered in any order, and need not be separated by spaces or any delimiters such as commas. For complete information about using these parenthetical options, see the section, Connectives, Modifiers, and Options in the INFO/ACCESS User Reference Guide.

Sorting File Items

The following example sorts all items in the INVENTORY file by book number and also displays the price of each book:

>SORT INVENTORY BY BOOK# WITH PRICE > “5.00” BOOK# PRICE

 

 

 

PAGE   1

13:39:09  dd mmm yyyy

 

 

 

INVENTORY

BOOK#

PRICE...

 

 

 

QR02

1

$10.75

N01

2

$12.50

QR01

3

$7.00

N02

4

$13.35

 

 

 

4 ITEMS LISTED.

 

 

 

>

 

 

Sorting By Multiple Attributes

The following example sorts the ORDERS file by customers’ last names and then by first names:

>SORT ORDERS BY LAST-NAME BY FIRST-NAME LAST-NAME FIRST-NAME

 

 

 

PAGE   1

12:47:08  dd mmm yyyy

 

 

 

ORDERS....

LAST NAME...

FIRST NAME...

 

 

 

10104

ASH

MARY

10109

ASH

MARY

10122

BUCKLER

JULIE

10105

EDGECOMB

DAVID

10115

EDGECOMB

DAVID

10113

JENKINS

HAROLD

10101

JOHNSON

ALICE

10111

JOHNSON

ALICE

10107

JOHNSON

HENRY

10102

LEARY

BILL

10108

LEARY

BILL

10112

LEARY

BILL

10114

LEARY

BILL

10106

ORLANDO

AMY

 

 

 

14 ITEMS LISTED.

 

 

 

 

 

>

 

 

Excluding Item-IDs from a Report

The following example displays the preceding report without listing item-IDs:

>SORT ORDERS BY LAST-NAME BY FIRST-NAME LAST-NAME FIRST-NAME ID-SUPP

 

 

PAGE   1

13:03:12  dd mmm yyyy

 

 

LAST NAME...

FIRST NAME...

 

 

ASH

MARY

ASH

MARY

BUCKLER

JULIE

EDGECOMB

DAVID

EDGECOMB

DAVID

JENKINS

HAROLD

JOHNSON

ALICE

JOHNSON

ALICE

JOHNSON

HENRY

LEARY

BILL

LEARY

BILL

LEARY

BILL

LEARY

BILL

ORLANDO

AMY

 

 

14 ITEMS LISTED.

 

 

 

>

 

Sorting MultiValued Items

In the following example, the ORDERS file contains a MultiValued attribute, TITLE, for the titles of books sold. The example sorts TITLE and displays ORDERS by the title of the book, the number of books sold, and the date they were sold.

>SORT ORDERS BY-EXP TITLE TITLE QTY DATE

 

 

 

 

PAGE   1

15:16:17  dd mmm yyyy

 

 

 

 

 

 

ORDERS.

TITLE....................

QTY

DATE OF ORDER

 

 

 

 

10101

DATABASE MANAGEMENT SYSTEMS

2

06 SEP 1994

10102

DATABASE MANAGEMENT SYSTEMS

1

21 OCT 1994

10104

DATABASE MANAGEMENT SYSTEMS

3

27 MAR 1994

10105

DATABASE MANAGEMENT SYSTEMS

1

17 MAR 1994

10107

DATABASE MANAGEMENT SYSTEMS

9

17 MAR 1994

10110

DATABASE MANAGEMENT SYSTEMS

12

25 DEC 1993

10114

DATABASE MANAGEMENT SYSTEMS

5

13 DEC 1993

10115

DATABASE MANAGEMENT SYSTEMS

1

11 JUL 1994

10102

OPERATING SYSTEM CONCEPTS

3

21 OCT 1994

10104

OPERATING SYSTEM CONCEPTS

5

27 MAR 1994

10106

OPERATING SYSTEM CONCEPTS

3

16 APR 1994

10107

OPERATING SYSTEM CONCEPTS

34

17 MAR 1994

10108

OPERATING SYSTEM CONCEPTS

10

30 MAR 1994

10110

OPERATING SYSTEM CONCEPTS

3

25 DEC 1993

10111

OPERATING SYSTEM CONCEPTS

6

29 SEP 1994

10112

OPERATING SYSTEM CONCEPTS

7

22 MAR 1994

10113

OPERATING SYSTEM CONCEPTS

4

02 JUN 1994

10115

OPERATING SYSTEM CONCEPTS

5

11 JUL 1994

10119

OPERATING SYSTEM CONCEPTS

2

23 JUN 1993

10124

OPERATING SYSTEM CONCEPTS

2

24 JUN 1993