postgresql - trouble to order a list obtained by string_agg
The order by in a string_agg() can absolutely use a CASE expression:

with data (ligne_code) as (
  values 
  ('a value'), ('09'), ('12'), ('20'), ('007'), 
  ('200'), ('92'), ('11'), ('Foo'), ('Exp3')
) 
select string_agg(ligne_code, ',' order by case when ligne_code ~'^[0-9]+$' then ligne_code::int end, ligne_code)
from data;


returns:

007,09,11,12,20,92,200,a value,Exp3,Foo


The expression when ligne_code ~'^[0-9]+$' checks if ligne_code consists of numbers. If that is the case it's converted to an integer which is the first sort criteria. All non-numbers come after that and are sorted in a alphabetic way.