Bugfix SQL bug invalid sort order