Add failing tests for issue #15
Avoid iterate full word when the diagonal value is greater or equal to max_distance
Fix: Diagonal index was not correctly calculated in some special cases when levenshtein matrix was not square
Reduce second loop to 2k-1 (where k is max_distance), when max_distance is specified
Tweak comments and remove trailing space
Be explicit when sorting is intended

It avoids duplication and makes the intention clearer.
Avoid for
Use a more common idiom for array initialisation

In addition, a < [b, c].min is the same as a < b || a < c, because if
it's less than the smaller, it'll definitely be less than the larger.
Expressing it this way is simpler, I think.
Prefer if/else to ternary
Tweak spacing and remove unnecessary parens
Optimise by dispatching early

Checking for max_distance results makes calculations take about 18%
longer when there's no maximum. Splitting it out into two methods
mitigates this.