Conteúdo do Curso
Google Spreadsheets
Google Spreadsheets
Sort Function
In this chapter we will explore the Sort Function. The SORT function allows you to sort data ranges based on values in one or more columns. This is useful for organizing data and analyzing information in a more digestible format. One of the main advantages of the SORT function is that it uses dynamic arrays, meaning the data automatically updates when values in the table change. This ensures that you always see the most up-to-date information without having to manually resort the data.
Syntax and Examples
SORT(range, sort_column, is_ascending, [sort_column2, is_ascending2, ...])
- range - The data to be sorted;
- sort_column - The column index in the range or a range outside the specified range containing values for sorting;
- The range specified as sort_column must be a single column with the same number of rows as the range;
- is_ascending - TRUE or FALSE (1 or -1), indicating whether the sort_column should be sorted in ascending order FALSE sorts in descending order;
- sort_column2, is_ascending2... - [OPTIONAL] Additional columns and sort order flags, specified in order of priority.
Input Data | Output Data | ||||
---|---|---|---|---|---|
Student (Value A) | Grade (Value B) | Formula | Student | Grade | |
Isabella | 95 | SORT(A2:B6, 2, 1) | Oliver | 73 | |
Liam | 92 | Emily | 85 | ||
Noah | 88 | Noah | 88 | ||
Emily | 85 | Liam | 92 | ||
Oliver | 73 | Isabella | 95 | ||
SORT(A2:B6, 2, -1) | Oliver | 73 | |||
Emily | 85 | ||||
Noah | 88 | ||||
Liam | 92 | ||||
Isabella | 95 | ||||
SORT(A2:B6, 1, 1) | Emily | 85 | |||
Isabella | 95 | ||||
Liam | 92 | ||||
Noah | 88 | ||||
Oliver | 73 |
SORT(A2:B6, 2, 1)
The formula sorts data by column B (Grade) in ascending order. Students are displayed starting from the lowest score.
SORT(A2:B6, 2, -1)
The formula sorts data by column B (Grade) in descending order. Students are displayed starting from the highest score.
SORT(A2:B6, 1, 1)
The formula sorts data by column A (Student) in alphabetical order. Students are displayed from A to Z.
Input Data | Output Data | ||||||
---|---|---|---|---|---|---|---|
ID (Value H) | Name (Value I) | Start Date (Value J) | Formula | ID | Name | Start Date | |
1 | Emily | 2022-01-15 | SORT(H3:J11, MONTH(J3:J11), TRUE) | 1 | Emily | 2022-01-15 | |
2 | Liam | 2021-05-10 | 7 | Elijah | 2024-01-22 | ||
3 | Noah | 2023-03-05 | 8 | Mia | 2023-02-14 | ||
4 | Oliver | 2020-08-20 | 3 | Noah | 2023-03-05 | ||
5 | Isabella | 2020-08-20 | 2 | Liam | 2021-05-10 | ||
6 | Ava | 2022-06-18 | 6 | Ava | 2022-06-18 | ||
7 | Elijah | 2024-01-22 | 4 | Oliver | 2020-08-20 | ||
8 | Mia | 2023-02-14 | 5 | Isabella | 2020-08-20 | ||
9 | Lucas | 2021-09-09 | 9 | Lucas | 2021-09-09 | ||
10 | Emma | 2023-10-01 | SORT(H3:J11, J3:J11, 1, I3:I11, 1) | 5 | Isabella | 2020-08-20 | |
4 | Oliver | 2020-08-20 | |||||
2 | Liam | 2021-05-10 | |||||
9 | Lucas | 2021-09-09 | |||||
1 | Emily | 2022-01-15 | |||||
6 | Ava | 2022-06-18 | |||||
8 | Mia | 2023-02-14 | |||||
3 | Noah | 2023-03-05 | |||||
7 | Elijah | 2024-01-22 |
SORT(H3:J11, MONTH(J3:J11), TRUE)
The formula sorts data by the month from column J (Start Date) in ascending order. People are displayed in order of their start dates throughout the year, starting from January.
SORT(H3:J11, J3:J11, 1, I3:I11, 1)
The formula sorts data first by column J (Start Date) in ascending order, and then by column I (Name) in alphabetical order for matching dates.
Obrigado pelo seu feedback!