Sort_Cursor_Array:
declare
function
"<" (L, R : String_Integer_Maps.Cursor) return Boolean is
LE : constant
Integer := Element (L); -- L freq
RE : constant
Integer := Element (R); -- R freq
begin
if LE = RE
then -- counts match, so
use word
return Key (L)
> Key (R); -- order to break
tie
else
return LE >
RE; -- sort in freq order
end if;
end
"<";
procedure Sort is new
Ada.Containers.Generic_Array_Sort
(Count_Type,
String_Integer_Maps.Cursor,
Cursor_Array,
"<");
begin
Sort (A);
end Sort_Cursor_Array;