From ebecf988ecd6f29e0404a9bf605a533692407149 Mon Sep 17 00:00:00 2001 From: kalmar Date: Thu, 26 Jan 2017 12:50:02 +0100 Subject: [PATCH] Sort keys in subst_dict by wordlength (in reverse) --- src/Groups.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Groups.jl b/src/Groups.jl index e99b4f3..0a4b434 100644 --- a/src/Groups.jl +++ b/src/Groups.jl @@ -223,8 +223,7 @@ function replace!(W::GWord, index, toreplace::GWord, replacement::GWord; asserts end function replace_all!{T}(W::GWord{T}, subst_dict::Dict{GWord{T}, GWord{T}}) - reduced = true - for toreplace in reverse!(sort!(collect(keys(subst_dict)))) + for toreplace in reverse!(sort!(collect(keys(subst_dict)),by=length)) replacement = subst_dict[toreplace] i = findfirst(W, toreplace) while i ≠ 0