-- sort.ada -- This is just the package body, Sort.ada or Sort.adb but you -- also need Sort_.ada or Sort.ads , the specification. -- Add additional "tag along" arrays as Arr2, Arr2, etc as desired -- change types of arrays as desired. -- Note: "Size" not needed, user can pass in a slice of an array. -- Later, this will be a Generic Package and types will not be hard coded. -- This is the simplest and slowest N**2 sort. package body Sort is procedure NNSort ( Size : Integer ; Arr1 : in out Int_Array ) is Temp : Integer ; begin for I in 1 .. Size - 1 loop for J in I + 1 .. Size loop if Arr1 ( I ) > Arr1 ( J ) then Temp := Arr1 ( I ) ; Arr1 ( I ) := Arr1 ( J ) ; Arr1 ( J ) := Temp ; end if ; end loop ; end loop ; end NNSort ; end Sort ; -- Below is the package specification, Sort_.ada or Sort.ads -- It should always come first! -- This is the contract with the user of the package. -- The body delivers the execution code. -- -- A typical package specification provides types and subprograms. -- This miniature provides one type and one subprogram. -- -- When considering name scope, think of the "end Sort;" removed from spec -- and the "package body Sort is" removed from the body, and the two -- pasted together where the statements are removed. package Sort is type Int_Array is array(Integer range <>) of Integer; procedure NNSort ( Size : Integer ; Arr1 : in out Int_Array ) ; end Sort ; -- When using gnat, gnatchop sort.ada produces the .adb and .ads files