Zdá se mi to poněkud neohrabané, ale teď mě nenapadá jednodušší řešení:
with val (col) as (
values (ARRAY['CAT','CAT DOG CAT','DOG Cat'])
), word_list as (
select unnest(col) as pc
from val
), wc as (
select array_length(string_to_array(pc, ' '),1) as word_count, pc
from word_list
)
select array_agg(pc order by word_count desc)
from wc;