In Google Sheets, a pivot table is sorted through its own settings, not by sorting its cells. Set the sort in the pivot table editor, and the order follows the pivot table’s settings.
Open the pivot table editor
Click any cell inside the pivot table. The pivot table editor opens in a side panel with Rows, Columns, Values and Filters sections, much like the areas in an Excel pivot table.
Sort rows by label
In the Rows section, find the sort setting for the row field. You can sort the labels from A to Z or from Z to A. Text labels sort alphabetically.
Sort rows by a value
To show the biggest totals first, sort by a value column, such as total sales, in descending order. Descending puts the largest figure at the top.
If the pivot table has more than one value column, choose the one you want to rank by. The sort uses that column’s totals.
Sort columns
The Columns section works in a similar way. Columns can be sorted by their labels or by a value, which helps when products or months should appear in a set order.
Dates and month names
Real dates sort in date order. Text labels, including month names typed as text, sort alphabetically, so April can come before February. If the order looks wrong, check the sort setting on that field and confirm the column holds real dates.
Sort a copy with a formula
If you need a sorted list outside the pivot table, such as on another sheet, use a formula. The SORT function can order a range by a chosen column, and the QUERY function can sort with an ORDER BY clause. For more ways to use it, see query function google sheets examples.
In Excel, the sort is set from the drop-down on the row labels, and formula-based sorting is a separate job. For that, see sort data with formula in excel.
When the sort seems to reset
If the order changes after you edit the source, check that the sort still points at a value column that exists. If you renamed or removed the column the sort used, choose the new column in the editor.