I need to sort through an array and check if there are more than 4 objects with the same property. Them if there are to compare them on another property of the object and remove them util there are only 4.
e.g.
var ARR:array = [{name:"Toshiba", points:"512"},
{name:"Toshiba", points:"156"},
{name:"Toshiba", points:"458"},
{name:"Toshiba", points:"256"},
{name:"Toshiba", points:"445"},
.....................................]
Basically I have to see if there are more than 4 toshiba’s in the array and if there are to splice the toshiba with the lowest points until there are only 4 left. I tried nesting loops to compare it with another array that only holds one of each names, but I have no idea how to then sort them on points and splice it :puzzled:
for (var y:Number = 0; y < Names.length; y++)
{
var b:Number = 0;
for (var x:Number = 0; x < ARR.length; x++)
{
if (ARR[x].name== Clubs[y].name)
{
b++;
}
}
if (b > 4)
{
trace(Clubs[y].name);
}