I need to find the shortest string in postgres. Searched around could not find any answers. My use case started from a aggregate function in SQL:
select key_col, strarr_shortest(text_col) as text_col
from (
select key_col, array_agg(tex_col::text) as text_col
from mytable group by key_col
) foo;
It turn out I have to write a pl/pgsql to solve this problem.