Created
April 27, 2012 03:02
-
-
Save nowri/2505333 to your computer and use it in GitHub Desktop.
中身がObject型のVectorをソートする
This file contains hidden or 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
//@see http://flashjp.com/as3/vector3.php | |
var vec:Vector.<Object> = new Vector.<Object>(); | |
vec[0] = { name:"apple" , price:98 }; | |
vec[1] = { name:"banana" , price:198 }; | |
vec[2] = { name:"chocolate" , price:148 }; | |
vec.sort(compareFunction); | |
function compareFunction(x:Object, y:Object):Number { | |
return x.price - y.price;//値が小さい順 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment