After a sort, optimal row height needs to be redone on all rows affected by sort.
Under Data>Sort…>Options tab do you have “Include formats” checked?
You might also check Maintaining row height when sorting data in Calc.
2 Likes