Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
.sort((a, b) => a[0] - b[0] || a[1] - b[1] || a[2] - b[2]);
Array.prototype.sort accepts a callback to define the sorting behavior.
This callback is designed to accept arrays as its arguments.
It first checks the first element of both arrays to see which has precedence. if the result of the operation is a non-zero it returns the result and is sorted based on that element.
If the result of the operation is 0, it means the 2 values are equal and should then be sorted by the second element.
The same operation is done on the second element and third element with the exception that it will return 0 if the operation on the third element is 0. In this case both arrays are shallowly equal in the first 3 elements.
This is the first time my code has resembled a Best Practice solution. Though I did not modify a String prototype, the majority of my solution reflects similiar to this. As noted from others I do see areas of optimization.