You can use the sort() function of JavaScript to sort the specified range of the array.
For example:
let arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10];
let start = 2;
let end = 5;
let sortedArr = arr.slice(start, end + 1).sort((a, b) => a - b).concat(arr.slice(0, start)).concat(arr.slice(end + 1));
console.log(sortedArr); // [1, 3, 5, 2, 4, 6, 7, 8, 9,