Probably the most useless sorting algorithm ever
A friend of mine sent me a coding challenge he'd been given by a potential employer, and I couldn't help but implement it.
Given a square, two-dimensional array (i.e. a matrix, ish), like this one:
[[1, 2, 3], [4, 5, 6], [7, 8, 9]];
it will walk around the "outer edge" of the matrix to generate the sort order, and then continue, spiralling inwards. Accordingly, it would return:
[1, 2, 3, 6, 9, 8, 7, 4, 5];
- Clone the repo
- Install dependencies using
yarn
ornpm install
- This will automatically install flow-typed library definitions.
Settings are provided for Visual Studio Code, as well as a .editorconfig file.
- Run unit tests using
npm test
oryarn test
- Run linting checks using
npm run eslint
oryarn eslint
- Run type checks using
npm run flow check
oryarn flow check