with ada.containers.Generic_Array_Sort; with ada.containers.Generic_Constrained_Array_Sort; with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; procedure gsort is type individual is record a, b: natural; end record; function "<"(l, r: individual) return boolean is (l.b < r.b); function gt(l, r: individual) return boolean is (l.a > r.a); subtype pop_range is natural range 1 .. 10; -- CONSTRAINED TYPE type population is array(pop_range) of individual; procedure c_sort is new ada.containers.Generic_Constrained_Array_Sort( Index_Type => pop_range ,Element_Type => individual ,Array_Type => population -- ,"<" => gt -- -- Default value for the param "<" is: -- -- any existing function named "<" of the correct type ); -- UNCONSTRAINED TYPE type upopulation is array(pop_range range <>) of individual; procedure u_sort is new ada.containers.Generic_Array_Sort( index_type => pop_range ,array_type => upopulation ,element_type=>individual ); -- By default, uses the above function < for individuals procedure put(pop: population) is begin for p of pop loop put(p.a); put(p.b); new_line; end loop; end put; pop: population ;-- := (others => (0, 0)); begin put(pop); c_sort(pop); new_line; put_line("after sorting"); put(pop); end gsort;