Sort a general ledger in Excel: by account, then by date

A general ledger export rarely arrives in a useful order. Lines from five accounts sit side by side, April entries follow May entries, and a large bill hides between two small bank fees. Sorting puts the lines in an order you can actually read. This page covers why accountants sort a ledger, single-level and multi-level sorts, sort directions, keeping each entry in one piece, and when a filter is the better tool.

Why sort a ledger export?

Each ledger line has a date, an account, a description, a reference such as a journal entry number, and an amount. Sorting changes only the order of the lines, and the right order depends on the question you are asking.

Sorting calculates nothing; for a total per account, see the page on SUMIFS totals by account.

How a sort works

A sort compares the values in one column, called the sort key, and rearranges the rows so those values run in order. Every other cell in the row travels with it. If row 9 holds an entry dated 4/20/2026 for Cash, the whole row moves together to wherever 4/20/2026 belongs.

That is the key idea on this page: a sort moves whole rows. The five cells of a ledger line describe one entry and must stay on the same row. If they come apart, the ledger is wrong, even though every value is still there.

Single-level sort

A single-level sort uses one key, such as Date, oldest first. It answers one question: in what order did things happen?

Multi-level sort ("then by")

A multi-level sort uses two or more keys in a fixed order of priority. The first level makes the groups. Each later level orders the rows inside those groups, and only breaks ties left by the levels above it.

Sort by Account A to Z, then by Date oldest first, and you get every Accounts Payable line together, in date order, followed by every Accounts Receivable line in date order, and so on. The second level never pulls a line out of its account group.

The order of the levels matters. Date first and Account second gives a very different result: the ledger is in date order, and Account only matters for two lines that share the same date.

Choosing a direction

Each level has a direction. The labels change with the type of data in the column, but there are always two choices.

Column holdsAscendingDescending
DatesOldest to newest (smallest to largest)Newest to oldest
Text, such as account namesA to ZZ to A
Numbers, such as amountsSmallest to largestLargest to smallest

Dates are stored as numbers, with later dates holding larger numbers, so "smallest to largest" on a date column means oldest first, the usual order for a ledger.

Text sorts alphabetically and ignores case. Watch for a leading space in a name: it can make an account sort out of place.

Blank cells go last

Empty cells in the sort column go to the bottom, whichever direction you choose. If a few lines are missing a date, they end up after the last dated entry. The incomplete lines collect in one place where you can fix them.

Headers stay at the top

A ledger export has a header row with labels such as Date, Account and Amount. The header is not data, and it must not be sorted in with the entries. The sort dialog has a setting called "My data has headers". When it is on, the first row of the range is treated as labels: it stays where it is, and its labels appear in the "Sort by" list so you can pick a column by name.

The spreadsheet usually detects the header row for you, but check the setting. If it is off, the column choices show as "Column A", "Column B", and the header row is sorted into the middle of the ledger.

Step by step: sort by account, then by date

  1. Click any cell inside the ledger table; the sort picks up the whole block around it.
  2. Open Sort from the Data menu or toolbar.
  3. Check that "My data has headers" is on, so the header row stays put.
  4. Sort by: Account, A to Z.
  5. Add level. Then by: Date, smallest to largest (oldest first).
  6. Confirm, then check that each account forms one block with its dates running forward.

For a largest-first review, keep Account as the first level and use Amount, largest to smallest, as the second.

Worked example: a two-level sort on a real export

Here are the first six lines of a ledger export, as they arrived. The full export has 20 lines across five accounts, in A5:E24, with headers in row 4.

DateAccountDescriptionRefAmount
5/22/2026Utilities ExpenseWaterJE-120$3,740.27
5/21/2026Accounts PayableSupplier billJE-117$8,333.24
4/24/2026Accounts ReceivableInvoice issuedJE-168$4,800.64
4/12/2026Utilities ExpenseWaterJE-141$7,709.38
4/20/2026CashCustomer receiptJE-118$2,040.32
5/12/2026Accounts ReceivableInvoice issuedJE-169$8,888.11

Accounts and months are mixed together. After a sort by Account A to Z, then by Date oldest first, the first eight rows of the result look like this:

DateAccountDescriptionRefAmount
4/9/2026Accounts PayableSupplier billJE-175$7,220.92
5/8/2026Accounts PayablePayment to supplierJE-176$871.12
5/15/2026Accounts PayableSupplier billJE-166$6,539.75
5/21/2026Accounts PayableSupplier billJE-117$8,333.24
4/24/2026Accounts ReceivableInvoice issuedJE-168$4,800.64
5/2/2026Accounts ReceivableCredit noteJE-146$5,345.66
5/12/2026Accounts ReceivableInvoice issuedJE-169$8,888.11
5/25/2026Accounts ReceivableInvoice issuedJE-159$5,064.35

The rest of the ledger follows the same pattern: four Cash lines from 4/1/2026 to 5/19/2026, four Rent Expense lines from 4/26/2026 to 5/20/2026, and four Utilities Expense lines from 4/8/2026 to 5/22/2026. Three things to notice:

A quick check for any sort: note the full line of two or three references before you start and find them again afterwards. If one now sits next to a different date or amount, the rows came apart.

Filter vs sort

Sorting and filtering are often used together, but they do different things.

To review one account, a filter is often quicker: turn on the filter and show only that account in the Account column. Clearing the filter brings every line back, exactly where it was. Because filtered rows still exist, a total over the whole column still includes them.

The tools combine well: sort by date first, then filter to one account, and you see that account's lines in date order. If you would rather pull matching lines into a separate area with a formula, the FILTER function does that, and the page on filtering transactions in Excel covers it.

Common mistakes and how to fix them

These are the mistakes our exercises check for.

Sorting only one column

Selecting just the Date column and sorting it puts the dates in order, but the other columns stay where they were. Each date now sits next to another entry's account and amount, and the ledger is scrambled. Undo straight away, select the whole table (or click one cell inside it) and sort it as one block.

Newest first

Largest to smallest on the date column puts the most recent entry on top. Choose smallest to largest.

Levels in the wrong order

With Date as the first level and Account as the second, the lines come out in date order with the accounts mixed together. The level that makes the groups goes first: Account, then Date.

Wrong direction inside each group

The accounts are grouped correctly, but inside each account the newest date or the smallest amount comes first. Check the direction on the second level: smallest to largest for oldest-first dates, largest to smallest for biggest-first amounts.

Sorting by amount only

For a "biggest entries in each account" review, a single sort on Amount ranks the whole ledger at once and mixes the accounts. Add Account as the first level and keep Amount as the second.

Filtering the wrong way round

When you filter to review one account, make sure the filter shows rows where the account equals the name you want. A condition of "does not equal" hides exactly the lines you meant to look at. Also check that you picked the right account name.

Where this fits in MO-220 practice

Organizing transactions with sort and filter is part of preparing data for a trial balance. Our MO-220 practice tasks describe the order you need rather than the clicks, so you learn to turn a review question into sort levels. Accounting Exercises is not affiliated with Microsoft or Certiport.

Frequently asked questions

How do I sort by account and then by date?

Click a cell in the table and open Sort. Sort by Account, A to Z. Add a level and set it to Date, smallest to largest. The first level groups the lines by account; the second puts each account's lines in date order.

Why did my sort mix up the rows?

Only one column was selected, so only that column moved. Undo, then sort the whole table so every cell in a row moves together.

What does "My data has headers" do?

It tells the sort that the first row holds labels. That row stays at the top, and its labels appear in the list of columns to sort by.

Where do blank cells go when I sort?

To the bottom, in both directions. Lines with a missing value in the sort column collect after the last filled line.

Does a filter delete the rows it hides?

No. Hidden rows are still in the sheet and keep their place. Clear the filter and they all reappear in their original order.

Practice it now: Sort the general ledger

A free exercise with new numbers every time. No sign-up.

Start the free exercise