AI Native challenges by level

Level 1 · Foundations · Data and input

Sort release versions

Compare numeric version segments with stable ties.

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"
]
Practice has no points, deadline or submission cap. Use AI and search freely. Sign in to run public examples, or verify locally.

73 / 20,000 characters

Add your test · optional

Enter a JSON argument array in versions order. Your test runs alongside the three examples.

Save both files in one folder and run this command with Node.js. Read the checks field for individual example results.

node verify-version-sort.mjs
문의하기

서비스명: 포트포올
문의는 운영자에게 이메일로 전송됩니다.

이메일과 문의 내용은 답변을 위해 운영자 및 메일 발송 서비스로 전송됩니다. 비밀번호·결제정보·민감한 개인정보는 입력하지 마세요.