AI

The .sort() method sorts arrays in place. By default it sorts as strings, so you need a compare function for numbers!

Your Task:

  • Sort names alphabetically (default sort is fine)
  • Sort prices numerically using (a, b) => a - b as the compare function
  • Store results in sortedNames and sortedPrices
TypeScript Solution
Loading...

Submit your code to see test results