function solution(arr, divisor) {
let newArray = [];
for (let i = 0; i < arr.length; i++) {
if (arr[i] % divisor === 0) {
newArray.push(arr[i]);
newArray.sort((a, b) => a - b);
}
}
if (newArray.length === 0) {
newArray.push(-1);
}
return newArray;
}
console.log(solution([5, 9, 7, 10], 5)); // [5,10]
console.log(solution([2, 36, 1, 3], 1)); // [1,2,3,36]
console.log(solution([3, 2, 6], 10)); // [-1]