-- TEST SHELL SORT USING X0SORT PACKAGE

with Instrument, X0sort;
use Instrument;



procedure Sorta2 is

    type Int_Array is array (Integer range <>) of Integer;

    package Int_Sort is new X0sort (Integer, Int_Array);

    use Int_Sort;

    My_List : Int_Array (1 .. 10);

begin

    Start ("SORTA2", "SHELL--IN ORDER, REVERSE ORD, OUT OF ORDER  " &
                        "(1000 REPETITIONS)");

    for Lcv in 1 .. 1000 loop

        for I in 1 .. 10 loop

            My_List (I) := I;

        end loop;

        Shsort (My_List);

        for I in 1 .. 10 loop

            if

               My_List (I) /= I

                then

                Comment ("DID NOT SORT THE NUMBERS PROPERLY FOR LIST IN ORD");

            end if;

        end loop;

        My_List (1) := 10;

        My_List (2) := 9;

        My_List (3) := 8;

        My_List (4) := 7;

        My_List (5) := 6;

        My_List (6) := 5;

        My_List (7) := 4;

        My_List (8) := 3;

        My_List (9) := 2;

        My_List (10) := 1;

        Shsort (My_List);

        for I in 1 .. 10 loop

            if

               My_List (I) /= I

                then

                Comment
                   ("DIDN'T SORT THE NUMBERS RIGHT FOR LIST IN REVERSE ORDER");

            end if;

        end loop;

        My_List (5) := 10;

        My_List (3) := 9;

        My_List (9) := 8;

        My_List (8) := 7;

        My_List (1) := 6;

        My_List (2) := 5;

        My_List (7) := 4;

        My_List (4) := 3;

        My_List (10) := 2;

        My_List (6) := 1;

        Shsort (My_List);

        for I in 1 .. 10 loop

            if

               My_List (I) /= I

                then

                Comment ("DIDN'T SORT THE NUMBERS RIGHT FOR OUT OF ORDER LIST");

            end if;

        end loop;

    end loop;
    Stop;

end Sorta2;