Problem statement
Write function solution(versions). Inputs and outputs are JSON values. Do not modify input arrays or objects. External libraries, network access, and asynchronous functions are not supported. versions:string[]. Each version has 1–8 dot-separated nonnegative integer segments, each at most 10^9; leading zeroes are allowed. Compare segments numerically, treating missing trailing segments as zero. Sort ascending, preserve input order for equal versions, and retain original strings. Input limits: at most 50,000 items per input array and 1,000 characters per string. Numbers are finite; integers and accumulated integer results stay in the JavaScript safe-integer range. Other types and validity rules follow the statement above.
Example input and output
Example 1
Function arguments
[
[
"1.10",
"1.2",
"2"
]
]Return value
[ "1.2", "1.10", "2" ]
Example 2
Function arguments
[
[
"1",
"1.0.0",
"0.9"
]
]Return value
[ "0.9", "1", "1.0.0" ]
Example 3
Function arguments
[
[
"3.3",
"3.03",
"3.2"
]
]Return value
[ "3.2", "3.3", "3.03" ]