Ascending sort is the default Easytrieve assumes when you list keys without a D suffix. Numbers climb from small to large. Names walk A toward Z under the collating sequence. Dates move earlier to later when defined as true date fields. Regions list 01 before 02 before 10 when defined as numeric—not always what beginners expect if they think of 10 as before 2 lexically. Most control-break reports want ascending major keys so subtotals read naturally down the page. This page explains default ascending behavior on SORT USING and REPORT SEQUENCE, how each field type compares, signed versus unsigned numeric traps, EBCDIC and ALTSEQ effects on characters, multi-key ascending stacks, when ascending is the wrong business choice, and test data you should build before production. Pair this with the Descending sort page when only some keys need reverse order.
1234SORT PERSNL TO SORTWRK USING (REGION, BRANCH, EMP#) REPORT R1 SEQUENCE DEPT EMP#
Neither example uses D, so every key sorts ascending. REGION 01 precedes 02. Within region 01, BRANCH 100 precedes 200. Within equal region and branch, lower EMP# precedes higher. SEQUENCE on a report follows identical default: DEPT ascending, EMP# ascending within department.
| Type | Ascending means | Example order |
|---|---|---|
| N unsigned | 0, 1, 2, 10, 99 | 10 after 2 numerically |
| N signed | Negative to positive per sign rules | -5 before +5 |
| P packed | Numeric magnitude | 1.00 before 9.99 |
| A alpha | Collating sequence low to high | A before B before Z |
| D date | Chronological early to late | Jan before Feb |
Display pictures mislead: zoned fields may show 02 before 10 while character fields might sort 10 before 2 if defined as alphanumeric text. Always know whether the key is N, P, or A in DEFINE.
12DEFINE WS-RANK W 3 N * Ascending: 1, 2, 3, 10 — not 1, 10, 2 as strings
On z/OS, A fields typically follow EBCDIC order unless your site installs an alternate sequence (ALTSEQ) for the sort utility or sets PARM SORT options. Punctuation and national characters sort relative to letters per that table—test with real data containing hyphens, spaces, and lowercase if allowed. Blank-filled keys sort before lower collating values in many sequences; trim or normalize in BEFORE if blanks should group last.
1SORT TRANS TO SORTWRK USING (ACCT-DATE, ACCT-NO, SEQ-NO)
Transaction files often need date ascending (oldest first), account ascending within date, sequence ascending within account. All three keys ascending suits audit trails and GL registers. A statement extract needing newest date first would put D on ACCT-DATE only—see descending page—not change major key order blindly.
CONTROL DEPT on a report expects DEPT values to increase (or at least change once per group) as the sorted file is read. Ascending DEPT in USING (..., DEPT) means department 100 prints completely before department 200—ideal for subtotals that accumulate low to high department codes. If marketing wants department 900 first, that is a descending or custom-order problem, not default ascending.
| Business need | Typical fix |
|---|---|
| Highest pay first within dept | GROSS D as minor key |
| Newest date first | DATE D as major or minor key |
| Z-to-A name list | NAME D on that key |
| Latest transaction per account after date sort | Ascending date then duplicate logic in JOB |
Ascending is counting up stairs: 1, 2, 3, 4. For letters in ABC order, A comes before B. Easytrieve does that by default for each sort key unless you put a D on that key to walk down the stairs instead.
1. Default sort order in USING is:
2. Ascending numeric N fields sort:
3. Ascending alphanumeric A fields follow:
4. USING (REGION, BRANCH) ascending means:
5. To keep default ascending on all keys you: