new fix in sorting of relations (performance increase)