The second loop compares values. j is the index used to get one value and j+1 is used to get the value to its right.