Sorted order for SQL execution