What is the correct fix?
const versions = ['1.10.0', '1.9.0']; versions.sort(); console.log(versions[0]);
- Compare each numeric part separately
- Compare with
localeComparedirectly - Pad every version to a fixed length
- Reverse the array after sorting it
String order puts '1.10.0' before '1.9.0'; compare the numbers segment by segment.
Play Problem Solving ▸