FAQ: Arrays - Accessing Elements

This is a very good example and i am clear now how the differences are. Thanks mtf.

1 Like

(This isn’t related to the lesson exercise specifically - but same topics. If this would be better posted somewhere else please point me in the right direction.)

If I have an array of strings (in this case names), what is an efficient way to sort or reorder them using arbitrary criteria?
Not alphabetical or numerical/UTC based methods.

Is there something more efficient than creating a function that will output the new “order” using index numbers & the console.log method repeatedly?

...
console.log(exampleList[0]);
console.log(exampleList[3]);
console.log(exampleList[1]);
console.log(exampleList[4]);
console.log(exampleList[2]);

or

console.log(exampleList[0], exampleList[3], exampleList[1], ....);

I don’t want to change the original array