Improve this function that compares jQuery versions Please help me improve this function that compares the jQuery version currently available (or not) with the one required.

function(need) {
    if (typeof(jQuery) != 'undefined') {
        if (!need) return true;
        var re = /(\d+)\.(\d+)\.(\d+)/,
            cur = re.exec(jQuery.fn.jquery),
            need = re.exec(need);
        return (need[1] &lt;= cur[1] &amp;&amp; need[2] &lt;= cur[2] &amp;&amp; need[3] &lt;= cur[3]);
    } else return false;
}
I'm sorry, but that code is completely broken. 


It doesn't work if either version contains only two numbers such as the current "1.6".
It uses string comparison instead of integer comparison, so that it will return true if you "need" (theoretical) version "1.4.10" but only "1.4.2" is included, because "10" &lt; "2" is true.
It doesn't stop comparing minor version numbers, if the major number is already bigger. For example it will return false if "1.4.2" is "needed", but "1.5.1" is included, because "2" &gt; "1"
And finally you should keep in mind that "newer" isn't necessarily better. For example, the new 1.6 version changes how .attr() works, and scripts that rely on the old functionality of .attr() may break.