Skip to content

Instantly share code, notes, and snippets.

@nowri
Created April 27, 2012 03:02
Show Gist options
  • Save nowri/2505333 to your computer and use it in GitHub Desktop.
Save nowri/2505333 to your computer and use it in GitHub Desktop.
中身がObject型のVectorをソートする
//@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