Fixed bug in KeepSortedRows