From docs (C++ qt but applies):
sortingEnabled : bool
This property holds whether sorting is enabled.
If this property is true, sorting is enabled for the table. If this property is false, sorting is not enabled. The default value is false.
Note:. Setting the property to true with setSortingEnabled() immediately triggers a call to sortByColumn() with the current sort section and order.
And if you check docs of QHeaderView (which is queried by the widget to know the column to sort by) you can read:
int QHeaderView::sortIndicatorSection () const
Returns the logical index of the section that has a sort indicator. By default this is section 0.
See also setSortIndicator(), sortIndicatorOrder(), and setSortIndicatorShown().
And:
Qt::SortOrder QHeaderView::sortIndicatorOrder () const
Returns the order for the sort indicator. If no section has a sort indicator the return value of this function is undefined.
So you should be careful with this