Skip to content

Commit

Permalink
Merge PR cosmos#4667: Sort events by type
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbez authored Jul 2, 2019
1 parent 0d3b4ba commit ef7e266
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package types

import (
"fmt"
"sort"
"strings"

abci "github.com/tendermint/tendermint/abci/types"
Expand Down Expand Up @@ -173,9 +174,18 @@ func (se StringEvents) Flatten() StringEvents {
flatEvents[e.Type] = append(flatEvents[e.Type], e.Attributes...)
}

var res StringEvents
for ty, attrs := range flatEvents {
res = append(res, StringEvent{Type: ty, Attributes: attrs})
var (
res StringEvents
keys []string
)

for ty := range flatEvents {
keys = append(keys, ty)
}

sort.Strings(keys)
for _, ty := range keys {
res = append(res, StringEvent{Type: ty, Attributes: flatEvents[ty]})
}

return res
Expand Down

0 comments on commit ef7e266

Please sign in to comment.