Hard
You need to sort an array of software version numbers following semantic versioning (major.minor.patch). Which implementation correctly sorts version numbers like "2.0.1" vs "2.1.0" vs "2.0.12"?
1const versions = [2 "1.0.0",3 "2.0.0",4 "1.9.1",5 "1.10.0",6 "2.0.1",7 "1.8.12",8 "1.9.2"9];1011function sortVersions(versions) {12 return versions.sort(/* Missing comparator function */);13}1415console.log(sortVersions(versions));