1. with Ada.Containers.Vectors; use Ada.Containers; 
  2.  
  3. package body Sorting_Tests is 
  4.  
  5.    --------------- 
  6.    -- Is_Sorted -- 
  7.    --------------- 
  8.  
  9.    function Is_Sorted (Field : Element_Array) return Boolean is 
  10.  
  11.    begin 
  12.       for ix in Field'First .. Index'Pred (Field'Last) loop 
  13.          if Field (Index'Succ (ix)) < Field (ix) then 
  14.             return False; 
  15.          end if; 
  16.       end loop; 
  17.       return True; 
  18.    end Is_Sorted; 
  19.  
  20.    -------------------- 
  21.    -- Is_Permutation -- 
  22.    -------------------- 
  23.  
  24.    function Is_Permutation (Field_A, Field_B : Element_Array) return Boolean is 
  25.  
  26.       package Field_Vectors is new Vectors (Positive, Element); 
  27.       use Field_Vectors; 
  28.  
  29.       package Field_Vectors_Sorting is new Generic_Sorting; 
  30.       use Field_Vectors_Sorting; 
  31.  
  32.       Vector_A, Vector_B : Vector := Empty_Vector; 
  33.  
  34.    begin 
  35.       for i in Field_A'Range loop 
  36.          Append (Vector_A, Field_A (i)); 
  37.       end loop; 
  38.       for i in Field_B'Range loop 
  39.          Append (Vector_B, Field_B (i)); 
  40.       end loop; 
  41.       Sort (Vector_A); 
  42.       Sort (Vector_B); 
  43.       return Vector_A = Vector_B; 
  44.    end Is_Permutation; 
  45.  
  46. end Sorting_Tests;