with inp as (
select 1 id from dual union all
select 2 from dual union all
select 3 from dual union all
select 4 from dual union all
select 5 from dual union all
select 6 from dual)
SELECT
id
FROM
inp
ORDER BY
abs( (
SELECT
AVG(id)
FROM
inp
) - id),
id;