# Getting the Index number of lowest 7 ints in list

I have a case where a certain amount of shots are used in each round and put into an int. I have several rounds and store them in a list. I want to know the index values of the 7 lowest ints in the list so i can find the rounds where the least amount of shots were done. I have looked at doing something like `shots.FindIndex` but i cant make it work. Any help would be appreciated

Code:

``````public List<int> shots = new List<int>();
public int bestScore;

// Use this for initialization
void Start()
{

}
``````

Another way to do this would be to use LINQ. You can use anonymous objects to make this a little easier:

``````		 hits.Select((x, i) => new { Shots = x, Index = i })
.OrderBy(x => x.Shots)
.Take(7)
.Select(x => x.Index);
``````

@Thephil2988

I think this is what you are going for. I typed it on my phone so I am not absolutely sure it will do what I think so it is a bit untested:

``````     public List<int> shots;
public int bestScore;

// Use this for initialization
void Start()
{
shots = new List<int>();
}

int Min() {
int lowestShots = INT_MAX;
for (int i = 0; i < hits.Count; i++ ) {
if (lowestShots < hits*) {*
``````

lowestsShots = hits*;*
}
return lowestsShots;
}
}
void Update() {
int lowestAmountOfShots;
lowestAmountOfShots = Min();
}

Create a list of records of type (“number of hits”, “index in the array”), fill it with actual values based on “hits” list, then sort the list (by “number of hits”) and use items with indices 0…6, extracting corresponding “index in the array” from the sorted list and use it as an index into “hits” like “hits[sortedList[0].indexInHits]”.
LINQ above perform the same procedure but there are some concerns about using LINQ in Unity (check https://forum.unity.com/threads/to-linq-or-not-to-linq.223887/)