var _ = require("lodash");

const impedance_type_sort = [ "single", "single_coplanar", "difference", "difference_coplanar" ];
var arr = [
    {
        impedance_type: 'difference_coplanar',
        signal1: 1,
        org_line_width1: 5
    },
    {
        impedance_type: 'difference_coplanar',
        signal1: 1,
        org_line_width1: 5.3
    },
    {
        impedance_type: 'difference_coplanar',
        signal1: 4,
        org_line_width1: 4.8
    },
    {
        impedance_type: 'single',
        signal1: 2,
        org_line_width1: 5
    },
    {
        impedance_type: 'single',
        signal1: 3,
        org_line_width1: 6
    },
    {
        impedance_type: 'difference_coplanar',
        signal1: 1,
        org_line_width1: 4.8
    },
];

arr = _.sortBy(arr, function(k) {
    return _.indexOf(impedance_type_sort, k.impedance_type);
}, function(k){
    return (k.signal1 == 1 || k.signal1 == 4) ? (1 + 4) : k.signal1;
}, 'org_line_width1', 'signal1');

print(JSON.stringify(arr, null, '  '));

