A dependency dashboard lists published versions of a package, like "1.10.0" and "1.2". Versions must be ordered by their numeric parts, not as text: 1.2.0 comes before 1.10.0.
Compare two versions part by part, as numbers, from left to right. A missing part counts as 0, so "1.2" and "1.2.0" are equal. Versions that are equal must keep their original order.
Write sortVersions(versions) that returns a new array with the versions in ascending order.
Input: versions = ["1.10.0","1.2.0","1.9"] Output: ["1.2.0","1.9","1.10.0"]
Second parts compare as numbers: 2 < 9 < 10.
Input: versions = ["2.0","1.2.0","1.2"] Output: ["1.2.0","1.2","2.0"]
1.2.0 and 1.2 are equal, so they keep their original order.
0 <= versions.length <= 10^50 to 10^6 joined by ..Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #218 Order Package Versions. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.