Skip to content
  • Projects
  • Groups
  • Snippets
  • Help
  • This project
    • Loading...
  • Sign in
Logo1

zhangtingyan / my-project

Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Settings
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Switch branch/tag
  • my-project
  • 数组sort.html
  • zhangtingyan's avatar
    文件复制 · 11324a7b
    zhangtingyan committed Mar 25, 2020
    11324a7b
数组sort.html 382 Bytes
RawBlameHistoryPermalink
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
<html>
<head>
</head>
<body>
<script>

var arr = ["10","5","40","25","1000","1"]
document.write(arr+"<br/>")
document.write(arr.sort()+"<br/>")

//从小到大
function sortNumber(a,b){
   return a - b
}
document.write(arr.sort(sortNumber)+"<br/>")

//从大到小
function sortNumber2(a,b){
   return b - a
}
document.write(arr.sort(sortNumber2)+"<br/>")

</script>
</body>
</html>