Skip to content

Instantly share code, notes, and snippets.

@nappa7878
Created November 4, 2013 06:02
Show Gist options
  • Save nappa7878/7298639 to your computer and use it in GitHub Desktop.
Save nappa7878/7298639 to your computer and use it in GitHub Desktop.
配列データの並び替え
function narabikae(){
//配列
var number = [500,4000,30,20000];
for (var i=0;i<number.length;i++) {
//配列をソート
number.sort(
function(a,b){
if( a < b ) return -1;
if( a > b ) return 1;
return 0;
}
);
}
//出力用
alert(number); // 30,500,4000,20000
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment