Skip to content

Instantly share code, notes, and snippets.

@nishinoshake
Last active May 29, 2016 05:04
Show Gist options
  • Save nishinoshake/5f36905769911c731631 to your computer and use it in GitHub Desktop.
Save nishinoshake/5f36905769911c731631 to your computer and use it in GitHub Desktop.
JSで配列のソート
;(function() {
var array = [39, 52, 110, 9, 8, 32];
console.log(array);
//数値の昇順ソート
console.log(array.sort(function(a, b){return a-b;}));
//数値の降順ソート
console.log(array.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