If statement - Comparing one items in a list for each items in a for loop


#1

Good day

Is the a way use a if statement in a for loop to compare each item in a list

and not one item at a time

I have 2 lists, and want to perform different functions for each items in the list when they are equal


#2

I think if you use two For Loops one after the other, you should be able to achieve what you’re trying to do.


#3

Yeah like @LJ-DJ said. Basically a simple sort function.

psuedo:

for (int i=0; i<length; i++)
{
for(int j=0;j<length;j++)
{
if($condition)
{ //do something}
}
}

#4

I am trying the two for loops but the condition is where the issue is…can’t break out of the for loop…


#5

Um, you need to have a break statement.

Debug your code


#6

got it sorted thanks


#7

Post your solution for other people when they search for this.


#8

Please let me know the solution as I am also stuck on this.

Thanks !


#9

What are you stuck on? Comparing of the two tables? perhaps post the piece here that you are stuck with?


#10

Hi,

I have posted my query on For loop with if statements
this post.
Can you please check that.