Можно сделать гораздо "дешевле", за один проход:
<div class="N" id="3"> </div>
<div class="N" id="1"> </div>
<div class="N" id="4"> </div>
<div class="N" id="2"> </div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
<script>
var $elements = $(".N");
var element = Array.prototype.reduce.call($elements, function (revious, current) {
return current.id > revious.id ? current : revious;
});
alert( element.id );
</script>