>>> compound_transpositions = [[2, 3], [3, 4], [4, 5], [5, 6]]
>>> coefficients = [17, 69, 84, 3, 46, 97, 12, 68, 70, 10]
>>> compound_transpositions.sort(key=lambda x: coefficients[x[0]]-coefficients[x[1]])
>>> compound_transpositions
[[4, 5], [3, 4], [2, 3], [5, 6]]
var x = {
y: 0.020,
z: 0.12345
};
console.log(JSON.stringify(x, function(key, value) {
return typeof value == 'number' ? value.toFixed(3) : value;
})); // "{"y":"0.020","z":"0.123"}"
console.log(JSON.stringify(x, function(key, value) {
return typeof value == 'number' ? Number(value.toFixed(3)) : value;
})); // "{"y":0.02,"z":0.123}"
ajax.json({
// ...
processData: false,
data: JSON.stringify(data)
// ...
});