def sort_string_by_pairs(strings):
    assert len(strings) % 2 == 0
    pairs = []
    strings = list(strings)
    while strings:
        template = strings.pop()
        for i, candidate in enumerate(strings):
            if count_string_diff(template, candidate) == 1:
                pair = [template, strings.pop(i)]
                pair.sort()
                pairs.append(pair)
                break
    return pairs