The SORT function allows you to specify which column to sort by. You can also include a hierarchy to sort by more than one column.
In the image below we have some letters and numbers in columns A and B.
To sort the list by the letters (the first column) you can use the following formula.
=SORT(A2:B7)
The SORT function defaults to sorting by the first column if you omit the second argument.
To sort by the second column (numbers) you would use.
=SORT(A2:B7,2)
Sort by multiple columns
What if you wanted to sort by more than one column? We can use what is called array syntax. This encloses the entries you want to use with braces (curly brackets) separated by commas.
To sort by column 1 and then by column 2 use.
=SORT(A2:B7,{1,2})
The third argument in the SORT allows you to specify the sort order, ascending or descending.
We can use the array syntax for that as well. The formula below sorts the first column in ascending order and the second column in descending order.
=SORT(A2:B7,{1,2},{1,-1})
Array syntax provides the flexibility to define dynamic multi-column sorting.
Please note: I reserve the right to delete comments that are offensive or off-topic.