I'm not sure how you're consuming the data, but computing a dictionary keyed by bonus type and target ("attack_luck") and containing the highest bonus might be faster and easier. If the entry doesn't exist, add it. If it does, update if higher.
@NautArch So, if I animate a bunch of skeletons to do manual labor, like clearing fields or powering a grain mill so that the village can enjoy a higher standard of living, that's okay?