@@ -1066,17 +1066,13 @@ func (p *resourcePopulator) populateResources(groupResourceTracker ResourceTrack
1066
1066
for asset := range groupResourceTracker .Assets {
1067
1067
groupResources .Assets = append (groupResources .Assets , asset )
1068
1068
}
1069
- slices .SortFunc (groupResources .Assets , func (a , b basics.AssetIndex ) int {
1070
- return cmp .Compare (a , b )
1071
- })
1069
+ slices .Sort (groupResources .Assets )
1072
1070
1073
1071
// Sort apps
1074
1072
for app := range groupResourceTracker .Apps {
1075
1073
groupResources .Apps = append (groupResources .Apps , app )
1076
1074
}
1077
- slices .SortFunc (groupResources .Apps , func (a , b basics.AppIndex ) int {
1078
- return cmp .Compare (a , b )
1079
- })
1075
+ slices .Sort (groupResources .Apps )
1080
1076
1081
1077
// Sort accounts
1082
1078
for account := range groupResourceTracker .Accounts {
@@ -1086,31 +1082,25 @@ func (p *resourcePopulator) populateResources(groupResourceTracker ResourceTrack
1086
1082
return cmp .Compare (a .GetUserAddress (), b .GetUserAddress ())
1087
1083
})
1088
1084
1089
- // Sort boxes
1090
- // To sort boxes, we turn the app into a string, concat with the name, and then sort
1091
- for box := range groupResourceTracker .Boxes {
1092
- groupResources .Boxes = append (groupResources .Boxes , box )
1093
- }
1085
+ // Sort boxes by app first and then name
1094
1086
slices .SortFunc (groupResources .Boxes , func (a , b logic.BoxRef ) int {
1095
- return cmp .Compare ( fmt . Sprintf ( "%d:%s" , a .App , a . Name ), fmt . Sprintf ( "%d:%s" , b . App , b .Name ))
1087
+ return cmp .Or ( cmp . Compare ( a .App , b . App ), cmp . Compare ( a . Name , b .Name ))
1096
1088
})
1097
1089
1098
- // Sort assets holdings
1099
- // To sort asset holdings, we turn the asset into a string, concat with the address, and then sort
1090
+ // Sort assets holdings by account first and then asset
1100
1091
for holding := range groupResourceTracker .AssetHoldings {
1101
1092
groupResources .AssetHoldings = append (groupResources .AssetHoldings , holding )
1102
1093
}
1103
1094
slices .SortFunc (groupResources .AssetHoldings , func (a , b ledgercore.AccountAsset ) int {
1104
- return cmp .Compare ( fmt . Sprintf ( "%d:%s" , a . Asset , a .Address ), fmt . Sprintf ( "%d:%s" , b .Asset , b .Address . GetUserAddress () ))
1095
+ return cmp .Or ( cmp . Compare ( a . Address . GetUserAddress (), b .Address . GetUserAddress ()), cmp . Compare ( a .Asset , b .Asset ))
1105
1096
})
1106
1097
1107
- // Sort app locals
1108
- // To sort app locals, we turn the app into a string, concat with the address, and then sort
1098
+ // Sort app locals by account first and then app
1109
1099
for local := range groupResourceTracker .AppLocals {
1110
1100
groupResources .AppLocals = append (groupResources .AppLocals , local )
1111
1101
}
1112
1102
slices .SortFunc (groupResources .AppLocals , func (a , b ledgercore.AccountApp ) int {
1113
- return cmp .Compare ( fmt . Sprintf ( "%d:%s" , a . App , a .Address ), fmt . Sprintf ( "%d:%s" , b .App , b .Address . GetUserAddress () ))
1103
+ return cmp .Or ( cmp . Compare ( a . Address . GetUserAddress (), b .Address . GetUserAddress ()), cmp . Compare ( a .App , b .App ))
1114
1104
})
1115
1105
1116
1106
// First populate resources that HAVE to be assigned to a specific transaction
@@ -1120,18 +1110,14 @@ func (p *resourcePopulator) populateResources(groupResourceTracker ResourceTrack
1120
1110
for asset := range tracker .Assets {
1121
1111
sortedAssets = append (sortedAssets , asset )
1122
1112
}
1123
- slices .SortFunc (sortedAssets , func (a , b basics.AssetIndex ) int {
1124
- return cmp .Compare (a , b )
1125
- })
1113
+ slices .Sort (sortedAssets )
1126
1114
1127
1115
// Sort apps
1128
1116
sortedApps := make ([]basics.AppIndex , 0 , len (tracker .Apps ))
1129
1117
for app := range tracker .Apps {
1130
1118
sortedApps = append (sortedApps , app )
1131
1119
}
1132
- slices .SortFunc (sortedApps , func (a , b basics.AppIndex ) int {
1133
- return cmp .Compare (a , b )
1134
- })
1120
+ slices .Sort (sortedApps )
1135
1121
1136
1122
// Sort accounts
1137
1123
sortedAccounts := make ([]basics.Address , 0 , len (tracker .Accounts ))
0 commit comments