![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
A=[2,3,8,4,1,0] alert(A.sort(null)) In Opera, FF and Safari, A.sort(null) returns the same array as A, but IE actually performs the default ascii-order sort. I would assume the majority of browsers here are following the ECMA-script standard. Is IE's behavior here a bug? |
|
If comparefn is not undefined and is not a consistent comparison function for the elements of this array (see below), the behaviour of sort is implementation-defined. [...] |
|
15.4.4.11 Array.prototype.sort (comparefn) The elements of this array are sorted. The sort is not necessarily stable (that is, elements that compare equal do not necessarily remain in their original order). If comparefn is not undefined, it should be a function that accepts two arguments x and y and returns a negative value if x < y, zero if x = y, or a positive value if x > y. |
#3
| |||
| |||
|
|
ddailey wrote: A=[2,3,8,4,1,0] alert(A.sort(null)) In Opera, FF and Safari, A.sort(null) returns the same array as A, but IE actually performs the default ascii-order sort. I would assume the majority of browsers here are following the ECMA-script standard. Is |
|
IE's behavior here a bug? It isn't: [...] |
#4
| |||
| |||
|
|
For reasons that are rather complicated, I have provided my JavaScript sort() method of an array with the null parameter (rather than an empty parameter list). A=[2,3,8,4,1,0] alert(A.sort(null)) In Opera, FF and Safari, A.sort(null) returns the same array as A, but IE actually performs the default ascii-order sort. I would assume the majority of browsers here are following the ECMA-script standard. Is IE's behavior here a bug? |
![]() |
| Thread Tools | |
| Display Modes | |
| |