package body Selection is procedure Swap(A, B : in out Element_T) is Temp : Element_T; begin Temp := A; A := B; B := Temp; end Swap; function Find_Largest(Arr : in Array_T) return Index_T is Max : Index_T; begin Max := Arr'First; for P in Index_T range Index_T'Succ(Arr'First) .. Arr'Last loop if Arr(P) > Arr(Max) then Max := P; end if; end loop; return Max; end Find_Largest; procedure Sort(Arr : in out Array_T) is Largest : Index_T; begin if Arr'Length <= 1 then return; end if; Largest := Find_Largest(Arr); Swap( Arr(Arr'Last), Arr(Largest) ); Sort( Arr(Arr'First .. Index_T'Pred(Arr'Last)) ); end Sort; end Selection;