Looking to develop a program that can determine if the elements in an array are sorted, I am working with three sets of input data:
1,2,3,4,5
1,2,8,9,9
1,2,2,3,2
Here is the code snippet I have come up with:
let sorts = +gets(); // 3
let list = [];
for (let i = 0; i < sorts; i++) {
list[i] = gets().split(',').map(Number); // The Array will be: [ [ 1, 2, 3, 4, 5 ], [ 1, 2, 8, 9, 9 ], [ 1, 2, 2, 3, 2 ] ]
}
for (let i = 0; i < list[i][i].length; i++){
if (list[i][i] < list[i][i +1]) {
print('true');
} else {
print('false');
}
}
The objective is to output true or false on individual lines for each list. Thus, the expected output for the given example should be as follows:
true
true
false
I would greatly appreciate any guidance on how to proceed with this task.