# How to Sort by Length in Google Sheets (With Example)

Often you may want to sort the strings in a column in Google Sheets based on character length.

Fortunately this is easy to do by using the LEN function.

The following step-by-step example shows exactly how to do so.

## Step 1: Enter the Data

First, let’s enter the names of various basketball teams in Google Sheets:

## Step 2: Calculate Length of Each String

Next, we will type the following formula into cell B2 to calculate the length of the string in cell A2:

`=LEN(A2)`

We can then click and drag this formula down to each remaining cell in column B:

The Length column displays the number of characters in each corresponding string in the Team column.

## Step 3: Sort Strings by Length

Next, highlight the cell range A2:B11, then click the Data tab along the top ribbon, then click Sort range, then click Advanced range sorting options:

In the new window that appears, choose to Sort by Column B from A to Z, then click Sort:

Once you click Sort, the team names will be sorted based on length from shortest to longest:

Note #1: If you would rather sort from longest to shortest length, then click Sort by Z to A instead.

Note #2: Feel free to delete the Length column once you’ve used it to sort the data.