# Compares two string versions, and returns -1, 0 or 1, according to the "<=>" # operator conventions def version_cmp(version_a, version_b) version_a.split(/\./).zip(version_b.split(/\./)) do |a,b| return -1 if a.nil? return 1 if b.nil? return a.to_i <=> b.to_i if (a.to_i <=> b.to_i) != 0 end # Just in case there's any characters return version_a <=> version_b end