Not sure why you need to order the values you're getting back by something other than the values themselves - is there a reason you wouldn't want the "children" set to be ordered numerically? You can still order the outer query by whatever you like, or you can order the aggregate by the values themselves, it's just the DISTINCT inside the aggregate query requires that an internal ORDER includes the ordering term in the result.