问题
Im sorting an array of objects alphabetically but not sure which way is more efficient. Im currently using the .sort() method and its working fine but would using the localeCompare() be a better alternative?
回答1:
The localeCompare
function is absurdly slow on many browser. Avoid it if possible. The other locale functions are really bad too, particularly the number to string ones.
来源:https://stackoverflow.com/questions/55695675/localecompare-vs-sort-for-alphabetically-sorting