Talk with any software engineer, and they will gladly tell you that software engineer interviewing is sorely broken.
Ranges are natively supported by a few (popular) programming languages. They allow for iteration over a defined space, while not having a linear increase in their memory footprint (all ranges always store a similar amount of data).
As sorting is a common operation on arrays, a more scalable and less error-prone strategy would be to define common compare functions. Let's build said compare functions!
A few years ago, ES6 introduced template literals, allowing among other things for multi-line strings, embedded expressions, and string interpolation. That means that the following snippets of code could be written as follow: