Table sorting bugfix