# Check array of objects for number of duplicates and splice specific ones

**URL:** <https://forum.kirupa.com/t/check-array-of-objects-for-number-of-duplicates-and-splice-specific-ones/331851>\
**Category:** flash\
**Created:** [November 7, 2013, 10:08am UTC](https://forum.kirupa.com/t/check-array-of-objects-for-number-of-duplicates-and-splice-specific-ones/331851 "2013-11-07T10:08:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![geHuC](https://avatars.discourse-cdn.com/v4/letter/g/7feea3/32.png) [@geHuC](https://forum.kirupa.com/u/geHuC)\
**Post date:** [November 7, 2013, 10:08am UTC](https://forum.kirupa.com/t/check-array-of-objects-for-number-of-duplicates-and-splice-specific-ones/331851/1 "2013-11-07T10:08:18Z")

</div>

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.

```auto

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:

```auto
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);
                    }

```
