2 * Function used to determine the order of the elements.
3 * It is expected to return
4 * - a negative value if the first argument is less than the second argument,
5 * - zero if they're equal,
6 * - and a positive value otherwise.
7 * If omitted, the elements are sorted in ascending, ASCII character order.
13 export function compare(a: string, b: string): number {
15 if (!/^\d+(\.\d+)*$/.test(a) || !/^\d+(\.\d+)*$/.test(b)) {
16 //throw new Error("Invalid version format");
21 const aParts = a.split(".");
22 const bParts = b.split(".");
24 for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {
25 const aPart = parseInt(aParts[i] || "0");
26 const bPart = parseInt(bParts[i] || "0");
30 } else if (aPart < bPart) {