Learn Basic Algorithmic Thinking by Building a Number Sorter - Step 44

Tell us what’s happening:

const sortedValues = inputValues.sort((a, b) => {
return a-b;
});
can someone tell me what is happening here. in case if b>a then -1 would be returned but how would the indexes change with the difference in these values ?

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

  const sortedValues = inputValues.sort((a, b) => {
    
  });

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36

Challenge Information:

Learn Basic Algorithmic Thinking by Building a Number Sorter - Step 44

hi there!

in your js file, what you have stored within above vriable.? sort() method have sorting that.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.