Maintain order of keys for Filter methods https://github.com/magiconair/properties/issues/4
diff --git a/README.md b/README.md index 3cb834c..d05d86b 100644 --- a/README.md +++ b/README.md
@@ -53,6 +53,10 @@ History ------- +v1.5.3, 02 Jun 2015 +------------------- + * [Issue #4](https://github.com/magiconair/properties/issues/4): Maintain key order in [Filter()](http://godoc.org/github.com/magiconair/properties#Properties.Filter), [FilterPrefix()](http://godoc.org/github.com/magiconair/properties#Properties.FilterPrefix) and [FilterRegexp()](http://godoc.org/github.com/magiconair/properties#Properties.FilterRegexp) + v1.5.2, 10 Apr 2015 ------------------- * [Issue #3](https://github.com/magiconair/properties/issues/3): Don't print comments in [WriteComment()](http://godoc.org/github.com/magiconair/properties#Properties.WriteComment) if they are all empty
diff --git a/properties.go b/properties.go index 33c108c..edcaccc 100644 --- a/properties.go +++ b/properties.go
@@ -425,9 +425,9 @@ // for which the key matches the regular expression. func (p *Properties) FilterRegexp(re *regexp.Regexp) *Properties { pp := NewProperties() - for k, v := range p.m { + for _, k := range p.k { if re.MatchString(k) { - pp.Set(k, v) + pp.Set(k, p.m[k]) } } return pp @@ -437,9 +437,9 @@ // for which the key starts with the prefix. func (p *Properties) FilterPrefix(prefix string) *Properties { pp := NewProperties() - for k, v := range p.m { + for _, k := range p.k { if strings.HasPrefix(k, prefix) { - pp.Set(k, v) + pp.Set(k, p.m[k]) } } return pp