Fixing sorting of rows