Google Sheets cannot sort by last name on its own, because it treats a full name in one cell as a single blob of text and sorts alphabetically by the first letter of that blob. The fix is to split each full name into separate first and last name columns, then run a normal sort on the last name column. If you only need to sort once, a temporary extra column with a formula is enough; if you plan to sort again later, keep the helper column so it is repeatable. You can do all of this on the desktop web version, and the same menu path works in the mobile app, though splitting text is much easier on a computer
What You'll Need
- A Google account and a spreadsheet with names in a single column (ideally formatted as "First Last" or as "Last, First" - you will need to know which before you start).
- A backup of the sheet if it matters: use File > Make a copy before sorting, because sorting rearranges rows and is hard to undo by hand after a few edits. Ctrl+Z (Cmd+Z on Mac) undoes a sort, but only until you make further changes.
- A decision about whether names are one or two words, because middle names, suffixes (Jr., III), and multi-word surnames change how you split.
One note on menus: labels in Google Sheets can differ slightly by version, device, or region. The paths below match the current desktop web app; on the mobile app, the same commands live in the three-dot menu at the top right instead of the Data menu.
Step-by-Step
- Confirm how the names are stored. Click a name cell and look at the formula bar. If it says "Maria Gonzalez", the first word is the first name. If it says "Gonzalez, Maria", the last name is everything before the comma. This determines how you split.
- Insert helper columns. Right-click the column header next to your name column and choose Insert 1 column right. Do this twice so you have two empty columns, one for the first name and one for the last name. Put a header in each, for example "First" and "Last".
- Split the names automatically. Select the whole name column (click the letter at the top), then go to Data > Split text to columns. In the small separator box that appears at the bottom of the selection, choose Space for "First Last" names. Google Sheets fills the neighbouring cells with the first and last name. If your names use "Last, First", choose Comma instead and then the last name ends up in the left cell and the first name in the right.
- Check what splitting did. With middle names, "Space" produces three pieces, so "Ana Maria Lopez" becomes Ana, Maria, Lopez and the surname lands in the third column, not the second. If your list has middle names or suffixes, splitting by space will not give a clean two-column result. In that case use a formula instead (see Step 5).
- Alternative: use a formula rather than splitting. In the first helper cell, type
=REGEXEXTRACT(A2,"\\S+$")to pull the last word of the name in A2 as the last name, and=LEFT(A2,LEN(A2)-LEN(REGEXEXTRACT(A2,"\\S+$"))-1)for the first name. Fill down by dragging the small blue square at the bottom-right of the selected cell. Formulas leave the original name intact and keep working when you add rows. - Copy the formula results if you plan to sort. Select the helper column, copy it, then use Edit > Paste special > Values only onto the same cells. This replaces the formulas with plain text, which prevents the references from scrambling after the sort. Sorting rows moves the formulas too, and a formula that pointed to A2 may now point somewhere else unless you locked it with dollar signs (
$A2). - Select the whole data range. Click the top-left cell of your table, hold Shift, and click the bottom-right cell. Include every column of each row so names stay with their emails, phone numbers, or other details. Do not select only the last name column - that is the most common way to wreck a sheet.
- Sort. Go to Data > Sort range > Advanced range sorting options. Tick Data has header row if your first row is a header. Choose your last name column from the Sort by dropdown. Pick A → Z for ascending or Z → A for descending, then click Sort.
- Decide about case sensitivity. Click the three-dot menu in the sort dialog and tick Case-sensitive sorting only if you need lowercase entries grouped separately. Normally leave it off, so "de la Cruz" sorts with "De La Cruz".
- Clean up. If the helper columns were temporary, delete them now with right-click > Delete column. If you want to keep them for future sorts, hide them instead with right-click > Hide column so the sheet looks tidy.
- Lock in the result if the sheet is shared. Select the range and use Data > Protect sheets and ranges if you want to prevent accidental re-sorting by others, though this protects cells rather than the sort order itself.
Common Mistakes
The biggest error is selecting one column and sorting it alone. Google Sheets will then ask whether to extend the selection; if you answer wrongly, the last names reorder while the rest of the row stays put, and every record is now mismatched. Always select the full table first.
The second is forgetting that sorting a range without checking the header row option pushes the header into the data. If "Last" ends up sorted between names, undo and repeat with Data has header row ticked.
Third, free-text names simply break alphabetical order when there are leading spaces or trailing spaces. A name typed with a stray space before the first letter sorts to the top of the list. Before sorting, run Data > Trim whitespace on the name columns.
Fourth, duplicated surnames look wrong after sorting only because the second sort key is missing. Add a second sort column (the first name) in the advanced sort dialog so two Gonzalezes appear as Maria then Pedro, not in random order.
Tips
For repeated sorting, make the last name a permanent column and treat the combined name as a display field. Use a formula such as =B2&", "&C2 to rebuild "Last, First" from the two helper columns, which reads nicely and still sorts correctly.
If you want to keep the original order as a fallback, add a numbered column (1, 2, 3...) at the start before you sort, then you can restore it later by sorting on that number.
Use filter views rather than sorting the sheet itself when several people share the file. Data > Filter views > Create new filter view lets you sort what you see without changing the order everyone else sees.
For very long lists, ARRAYFORMULA fills an entire column at once, for example =ARRAYFORMULA(IF(A2:A="","",REGEXEXTRACT(A2:A,"\\S+$"))) in the header row of an empty helper column.
Troubleshooting
The sort dialog is greyed out. You are probably in a filter view or a protected range. Close the filter view first, or ask the owner to lift the protection.
Only some rows moved. The selected range did not cover all rows. Undo with Ctrl+Z (Cmd+Z on Mac), then select from the first data row to the last, across every used column.
Names split into the wrong columns. That is the middle-name and comma problem. Clear the split result and use the regex formula instead, which takes only the final word as the surname.
The helper formulas now show errors after sorting. Their references moved. Undo the sort, convert the helpers to plain values first with Paste special > Values only, and sort again.
Accented names sort oddly. Confirm the names are in the same script and spelling; Google Sheets generally handles accents, but mixed scripts and inconsistent capitalisation can look out of order.
Frequently Asked Questions
Can I sort by last name without adding a column?
Not directly. Google Sheets has no built-in last-name sort. You need either a split column or a formula column, then sort on that column.
How do I sort names written as "Last, First"?
Use Data > Split text to columns with the comma separator. The surname then sits in the left cell and sorts correctly with a normal A to Z sort.
Will sorting break my formulas elsewhere?
Cell references inside the sorted range move with their rows, so relative references usually stay correct. Links to cells outside the range may point to the wrong row; check a few before relying on totals.
What about names with two surnames, like "Garcia Lopez"?
Neither a space split nor a last-word formula handles this perfectly. Add a third helper column and type the full compound surname manually, or let the formula take the last two words.
Does this work in the Google Sheets mobile app?
Sorting works through the three-dot menu, but splitting text and editing formulas is fiddly on a phone. Do the setup on a computer and sort on mobile afterwards.