# File lib/rubygems/gem_commands.rb, line 1012
    def which_to_update(highest_installed_gems, remote_gemspecs)
      result = []
      highest_installed_gems.each do |l_name, l_spec|
        highest_remote_gem =
          remote_gemspecs.select  { |spec| spec.name == l_name }.
                          sort_by { |spec| spec.version }.
                          last
        if highest_remote_gem and l_spec.version < highest_remote_gem.version
          result << l_name
        end
      end
      result
    end