Difficulty: 5/10Array.prototype.sort, In-place Mutation, Comparator FunctionsExample code:CopyScenario Questions0-2 years experience1We have a list of user ages like `[9, 21, 100, 5]`. A junior developer wrote `ages.sort()` to display them in ascending order, but the UI is showing `[100, 21, 5, 9]`. What is happening under the hood here, and how would you fix it?2Imagine you are building a React component that displays a list of products. You receive the products array from props, sort it by price using `products.sort(...)`, and render it. However, you notice that this is causing unexpected side effects elsewhere in the app where the same product list is used. Why is this happening, and how would you safely sort the array?2-5 years experienceFollow-up QuestionsWhat is the time and space complexity of the sorting algorithm used in modern JS engines like V8?How does the default sort behavior handle 'undefined' or missing values in an array?If you need to sort an array without mutating the original, what modern ES2023 array method would you use instead?Suggest Improvement