6
rated 0 times
[
9]
[
3]
/ answers: 1 / hits: 15109
/ 10 Years ago, tue, february 11, 2014, 12:00:00
Noticed something potentially odd with JavaScript's sort()
method. Given the following array:
var arr = ['Aaa',
'CUSTREF',
'Copy a template',
'Copy of Statementsmm',
'Copy1 of Default Email Template',
'Copy11',
'Cust',
'Statements',
'zzzz'];
Calling sort on this array:
console.log(arr.sort());
Yields:
[Aaa, CUSTREF, Copy a template, Copy of Statementsmm, Copy1 of Default Email Template, Copy11, Cust, Statements, zzzz]
Is this correct? ie. CUSTREF
is listed first, is this because of it's capital letters?
More From » javascript