Sorting by multiple fields
You can further sort the records in the bookstore data set by specifying multiple control fields. When you specify two or more control fields, you specify them in the order of greater to lesser priority. Note that control fields might overlap or be contained within other control fields.
- Course department
- Course number
- Instructor's last name
- Instructor's initials
- Book title.
So, if two records have the same department, they are sorted by course number. If they also have the same course number, they are sorted by instructor's last name. If they also have the same last name, they are sorted by initials. Finally, if they also have the same initials, they are sorted by title.

The records are sorted as shown in Table 1.
| Book Title | Course
Department |
Course
Number |
Instructor's
Last Name |
Instructor's
Initials |
|---|---|---|---|---|
1 75
|
110 114
|
115 119
|
145 159
|
160 161
|
LIVING WELL ON A SMALL BUDGET
PICK'S POCKET DICTIONARY INTRODUCTION TO BIOLOGY STRATEGIC MARKETING SUPPLYING THE DEMAND NUMBERING SYSTEMS COMPUTER LANGUAGES COMPUTERS: AN INTRODUCTION SYSTEM PROGRAMMING VIDEO GAME DESIGN SHORT STORIES AND TALL TALES EDITING SOFTWARE MANUALS THE COMPLETE PROOFREADER INKLINGS: AN ANTHOLOGY OF YOUNG POETS MODERN ANTHOLOGY OF WOMEN POETS THE INDUSTRIAL REVOLUTION CRISES OF THE MIDDLE AGES EIGHTEENTH CENTURY EUROPE INTRODUCTION TO PSYCHOLOGY ADVANCED TOPICS IN PSYCHOANALYSIS |
BIOL BUSIN BUSIN COMP COMP COMP COMP COMP ENGL ENGL ENGL ENGL ENGL HIST HIST HIST PSYCH PSYCH |
80521 70124 70251 00032 00032 00032 00103 00205 10054 10347 10347 10856 10856 50420 50521 50632 30016 30975 |
GREENBERG LORCH MAXWELL CHATTERJEE CHATTERJEE CHATTERJEE SMITH NEUMANN BUCK MADRID MADRID FRIEDMAN FRIEDMAN GOODGOLD WILLERTON BISCARDI ZABOSKI NAKATSU |
HC HH RF AN CL CL DC LB GR MM MM KR KR ST DW HR RL FL |
You can often shorten the length of control statements. You can specify fields together whenever they are next to each other in the record and have the same data format and order. You can shorten this last statement by specifying the department and course number together as one field, and the instructor's last name and initials together as one field.

SORT FORMAT=CH,FIELDS=(110,10,A,145,17,A,1,75,A) SORT FORMAT=CH,FIELDS=(110,10,A,170,4,BI,D,145,17,A,1,75,A) SORT FIELDS=(110,10,CH,A,170,4,BI,D,145,17,CH,A,1,75,CH,A)SORT FIELDS=(5,4,FI,A,345,400,UTF16,D,13,2,CH,A)