outbound/hmail.js
function sort_mx (mx_list) {
    const sorted = mx_list.sort((a,b) => a.priority - b.priority);

    // This isn't a very good shuffle but it'll do for now.
    for (let i=0,l=sorted.length-1; i<l; i++) {
        if (sorted[i].priority === sorted[i+1].priority) {
            if (Math.round(Math.random())) { // 0 or 1
                const j = sorted[i];
                sorted[i] = sorted[i+1];
                sorted[i+1] = j;
            }
        }
    }
    return sorted;
}
function sort_mx (mx_list) {
    const sorted = mx_list.sort((a,b) => a.priority - b.priority);

    // This isn't a very good shuffle but it'll do for now.
    for (let i=0,l=sorted.length-1; i<l; i++) {
        if (sorted[i].priority === sorted[i+1].priority) {
            if (Math.round(Math.random())) { // 0 or 1
                const j = sorted[i];
                sorted[i] = sorted[i+1];
                sorted[i+1] = j;
            }
        }
    }
    return sorted;
}
function sort_mx ( mx_list ) { const sorted = mx_list . sort ( ( a , b ) => a . priority - b . priority ) ; // This isn't a very good shuffle but it'll do for now. for ( let i = 0 , l = sorted . length - 1 ; i < l ; i ++ ) { if ( sorted [ i ] . priority === sorted [ i + 1 ] . priority ) { if ( Math . round ( Math . random ( ) ) ) { // 0 or 1 const j = sorted [ i ] ; sorted [ i ] = sorted [ i + 1 ] ; sorted [ i + 1 ] = j ; } } } return sorted ; }
MXs must be sorted by priority order, but matched priorities must be randomly shuffled in that list, so this is a bit complex.
MXs must be sorted by priority order but matched priorities must be randomly shuffled in that list so this is a bit complex .