I have the following problem with sorting in proxy class derived from QSortFilterProxyModel:
The class overwrites the filterAcceptsRow() and lessThen() methods. The source model for this proxy is a class derived from QAbstractTableModel.
After removing of some rows from the source model (always first rows are removed), I call invalidate() on the proxy model:

beginRemoveRows(QModelIndex(), 0, n);
// removing rows from the list
m_proxyModel->invalidate(); // proxy known to the source model

The filterAcceptsRow() is than called with valid indexes (according to the current list size), but the lessThen() method is called with INVALID (old?) indexes (currently bigger than the size of the list) - as I suppose resulting from the previous or first call to the filterAcceptsRow() method.

e.g. before removing rows the size of the list was 10, filtered rows in proxy model were 6 and 8. After removing of first 3 rows, the filterAcceptsRow() is sequentially called with indexes 0-6, but the lessThen() method is called with pair of indexes, where one of them (usually the second) is still 8!.
Of course the rowCount() of the source model returns the correct number of rows == list.size()

THX for any suggestions