Skip to content

Commit

Permalink
ENHANCE: Added option to control use of sorting dictionaries
Browse files Browse the repository at this point in the history
  • Loading branch information
hulpke committed Jan 21, 2020
1 parent b896eb2 commit b223921
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/dict.gi
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ end);
#F NewDictionary(<objcoll>,<look>)
##
InstallGlobalFunction(NewDictionary,function(arg)
local hashfun,obj,dom,lookup,maxblist;
local hashfun,obj,dom,lookup,maxblist,forcesort;
obj:=arg[1];
lookup:=arg[2];
if Length(arg)>2 then
Expand Down Expand Up @@ -362,8 +362,9 @@ local hashfun,obj,dom,lookup,maxblist;
fi;

# can we sort the elements cheaply?
if CanEasilySortElements(obj) then
Info(InfoHash,1,obj," Sort dictionary");
forcesort:=ValueOption("usesortdictionary");
if forcesort=true or (forcesort<>false and CanEasilySortElements(obj)) then
Info(InfoHash,2,obj," Sort dictionary");
return DictionaryBySort(lookup);
fi;

Expand Down

0 comments on commit b223921

Please sign in to comment.