I have the following code:
var r = [
['Pipe repair', '3 Bravo', 'Household Baker'],
['New connection', '5 Delta', 'Household Griffith'],
['Pipe repair', '3 Bravo', 'Household Baker'],
];
r = r.sort(function(a, b) {
return (a[0] > b[0]) ? 1: 0;
// EDIT: I mistakingly copied newer code than the original code I was testing. However the answer was still on point.
// The original code (that worked in Chrome but not Safari or my Rhino environment):
// return a[0] > b[0];
});
console.log(r)
Google Chrome produces a sorted output, as does node.js. However Safari does not (and probably older versions of firefox do not either). This script is being run by the Rhino interpreter within an Android app
How can I achieve this same sort across all browsers (I'm making the assumption that that will solve the problem on the platform where this script is being executed)?
1or0…and probably older versions of firefox do not either- firefox has supported array#sort(fn) since 1.0