creationix/nvm — pull request #100 by carter-thaxton (2012-02-05 07:11:46+00:00)
Title: Fix version sorting to handle multi-digit values like v0.6.10

As of the recent v0.6.10 release of node, nvm version no longer correctly handles the version sorting.

There are really two bug fixes here, both to the way nvm uses the 'sort' command.

First, the argument "2,1n" is illegal, and was being ignored, because position 2 is after 1, and it causes sort to incorrectly interpret the later keys like "2,2n" and "3,3n" as well. That's why v0.6.10 is exercising the problem.

However, even if we changed it to "1,1n", it still wouldn't quite work for "v1.0.0".

That's because "-t." tells sort to break up v0.6.10 into "v0" "6", "10", and unfortunately "v0" is not numeric at all, so it would not correctly sort "v0" before "v1".

So, by removing the "n" argument, it simply sorts the first part using ASCII, which will work up until node hits "v10.0.0". I can live with that. :)

FWIW, I think skipping over the "v" may have been why the "2,1n" slipped in there in the first place, but it clearly didn't work.