def fold_whoopsies(whoopsies1, whoopsies2):
    """ Merge whoopsies2 into whoopsies1
        sorted on query, then descending on magnitude
        of the whoops (so biggest whoops for queries come first)"""
    whoopsies1.extend(whoopsies2)
    whoopsies1.sort(key=lambda x: (x.qid, 1000-x.magnitude()))
    return whoopsies1