var array = [ {name: 'a', phone: 1, value: 'val_4'}, {name: 'b', phone: 5, value: 'val_3'}, {name: 'd', phone: 3, value: 'val_2'}, {name: 'c', phone: 4, value: 'val_1'} ] array.sort(getSortFun('desc', 'phone')); function getSortFun(order, sortBy) { v