Utah Community Learning

Sorting a table without scrambling the whole thing

About 20 minutes

Sorting a table without scrambling the whole thing

Okay sooo. Last lesson we set up columns for dates and entries on the tracking sheet. Real basic stuff, one row per thing you're tracking. Today we're sorting that table, because eventually you're gonna want to see it oldest to newest, or biggest to smallest, and if you sort it wrong you can genuinely scramble your data without realizing it right away.

Casey found this one out the hard way. I tried to teach him how to sort a table and he immediately clicked the little sort arrow on just one column header, not the whole table, and it sorted THAT column and left every other column sitting still. So suddenly the dates didn't match the entries anymore. Everything looked fine, nothing had an error in it, it was just quietly wrong. I fixed it in about ten seconds but he still brings it up like it was somehow my fault. It wasn't. It's just what the button does if you don't tell it otherwise.

Here's the thing. That's the actual danger with sorting. It's not going to yell at you. There's no red error message. Your money tracker will just sit there looking normal while row 12's date is attached to row 40's entry. You won't catch it until something looks weird three weeks from now and you can't figure out why.

Selecting the whole table first

The fix is simple and I want you to actually do this every single time, not just the first time.

  1. Click into any cell in your table.
  2. Select the whole range, all your columns, all your rows with data in them. In Google Sheets you can click the little corner box or just drag-select from your top-left cell to your bottom-right cell. In Excel, same idea, drag to select everything.
  3. THEN sort.

In Google Sheets, once you've got the range selected, go to Data, then Sort range. It'll ask if your data has a header row, say yes, then pick which column you want to sort by. In Excel it's Data, then Sort, and it'll usually offer to "expand the selection" automatically if it notices you've got more columns next to what you selected, say yes to that too.

The whole point is you want every row to move together as a unit. Date, entry, category, all of it travels as a package. If you only select one column, that column goes on its own little trip and leaves everyone else behind.

A shortcut that's actually safer

If your data is in an actual formatted table (not just cells with a header row, but a real Table object), both Google Sheets and Excel are smarter about this. The little dropdown arrows on your header row will sort the whole table automatically, because the table knows its own boundaries. That's honestly the safer setup for a beginner, less to remember, less to mess up.

Not gonna lie, I don't always bother making a formal Table object for something quick and small. For a real tracking sheet you're gonna use for months, it's worth the two extra minutes to set it up as a Table once. Future you will thank present you.

Sort by what question you're asking

Don't just sort for the sake of sorting. Ask yourself what you actually want to know first. Oldest first if you want to see how things built up over time. Newest first if you just want to see what happened most recently without scrolling to the bottom. Biggest number first if you're trying to find your worst month or your best one.

That's my whole opinion on spreadsheets in one sentence, honestly. Most people don't have a spreadsheet problem, they have a question problem. Sorting is a good example, because if you don't know what you're trying to see, you'll sort it three different ways and just feel more confused, not less.

A quick aside on being technically right

I had a coworker once who was VERY confident that a certain function (VLOOKUP, if you're curious) couldn't look to the left of its own reference column. He was wrong about WHY, there's actually a workaround, but he was right that it's annoying and most people don't bother with the workaround. I told him so, out loud, in front of people. Being right about the annoying part still counts as being right.

I bring that up because sorting has a similar flavor. People get very confident about "I always just click the column header" and are technically doing something, it's just not the thing they think it's doing. Confidence and correctness aren't the same. Check your work after you sort, at least the first few times, until it's a habit.

Undo is your friend here

One real caution: if you sort and it looks wrong, hit undo immediately, don't try to manually fix it by dragging rows around. Ctrl+Z (or Cmd+Z) will put it right back. Trying to hand-fix a scrambled table is how you make it worse. And obviously, autosave should be on, we've talked about that, so even if you close the file confused you haven't lost anything.

Before next time

Go sort your tracking sheet by date, oldest first, using the full-range method. Then look at three random rows and make sure the entry still matches the date you remember writing down. If it does, that's the sheet working.

  • C