Sorting DOM elements with sort () error in IE9-10
I have this code, which works fine in recent browsers Chrome, Firefox, Opera, but does not work in IE9-10:
var div = document.querySelector('#wrap'),
para = document.querySelectorAll('#wrap p');
var paraArr = [].slice.call( para ).sort(function( a,b ) {
return a.textContent > b.textContent;
});
paraArr.forEach(function( p ) {
div.appendChild( p );
});
script: http://jsfiddle.net/2nUMk/1/
Any ideas what the problem is? Is the implementation sort
not the same in IE as in other browsers? Is there even a problem here sort
?
+3
source to share