I have a vector of fixed length 9 with some objects. each object has a variable value:Point and the vector shall be sorted such that objects with a higher value.x appear first – and if theyr value.x is the same, then the one with the smaller value.y shall be first.
this is my compare function:
private function cmpr(h1:HelpObj, h2:HelpObj):Number{
var res:Number;
if(h1.value.x==h2.value.x){
res = h1.value.y-h2.value.y;
return res;
}
else{
res = h2.value.x-h1.value.x;
return res;
}
}
but as you can see on this screenshot, the resulting order is not what it’s supposed to be:

what am I doing wrong?
Compare function recieves arguments
aandb.It must return
ahas to be placed beforebbandaare equalahas to be placed afterbYou are returning whatever values, not just those three listed, which is why order gets messed up.
Compare the results in example below.
EDIT In your case that would be the following: