Created
November 4, 2013 06:02
-
-
Save nappa7878/7298639 to your computer and use it in GitHub Desktop.
配列データの並び替え
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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