How can you sort by length in Google Sheets with an example?

In Google Sheets, you can use the SORT function to sort data by length. This function allows you to specify a range of cells and a sort index, which determines the column to use for sorting. For example, if you have a list of names in column A and want to sort them by the length of the names, you can use the formula =SORT(A2:A10,LEN(A2:A10),TRUE). This will sort the names in ascending order based on their length, with the shortest names appearing first. You can also use the DESCENDING argument to sort the names in descending order. This feature can be useful for organizing data and finding patterns based on length.


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:

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.

Additional Resources

The following tutorials explain how to perform other common operations in Google Sheets:

x