Skip to content

Instantly share code, notes, and snippets.

@janily
Forked from sofish/sort.js
Created August 7, 2013 06:12
Show Gist options
  • Save janily/6171644 to your computer and use it in GitHub Desktop.
Save janily/6171644 to your computer and use it in GitHub Desktop.
// firefox 和 chrome 是 [1024, 6, 5, 3, 2, 1]
// safari 中顺序没变
[1,3,2,5,6,1024].sort(function(a, b) {
return b > a;
});
// 在各中浏览器工作一致的方法
// 用正负和零来排序,而不是 true/false
[1,3,2,5,6,1024].sort(function(a, b) {
return b - a;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment