def reorder_srv(records):
records = list(records)<EOL>records.sort()<EOL>ret = []<EOL>tmp = []<EOL>for rrecord in records:<EOL><INDENT>if not tmp or rrecord.priority == tmp[<NUM_LIT:0>].priority:<EOL><INDENT>tmp.append(rrecord)<EOL>continue<EOL><DEDENT>ret += shuffle_srv(tmp)<EOL>tmp = [rrecord]<EOL><DEDENT>if tmp:<EOL><INDENT>ret += shuffle_srv(tmp)<EOL><DEDENT>return ret<EOL>
Reorder SRV records using their priorities and weights.

    :Parameters:
        - `records`: SRV records to shuffle.
    :Types:
        - `records`: `list` of :dns:`dns.rdtypes.IN.SRV`

    :return: reordered records.
    :returntype: `list` of :dns:`dns.rdtypes.IN.SRV`