Logo

Programming-Idioms

History of Idiom 100 > diff from v14 to v15

Edit summary for version 15 by :
New Ada implementation by user [Smaehtin]

Version 14

2016-02-16, 19:02:23

Version 15

2016-02-17, 17:33:51

Idiom #100 Sort by a comparator

Sort elements of array-like collection items, using a comparator c.

Idiom #100 Sort by a comparator

Sort elements of array-like collection items, using a comparator c.

Imports
with Ada.Containers.Vectors;
use Ada.Containers;
Code
      type Integer_Comparator is not null access function (Left, Right : Integer) return Boolean;
      
      package Integer_Vectors is new Vectors (Positive, Integer);
      use Integer_Vectors;
      
      procedure Sort_Using_Comparator (V : in out Vector; C : Integer_Comparator) is
         package Vector_Sorting is new Generic_Sorting (C.all);
         use Vector_Sorting;
         
      begin
         Sort (V);
      end Sort_Using_Comparator;