re-implementing compare-locales in javascript/treehugger