# File lib/rubygems/commands/update_command.rb, line 133
  def which_to_update(highest_installed_gems, remote_gemspecs)
    result = []

    highest_installed_gems.each do |l_name, l_spec|
      matching_gems = remote_gemspecs.select do |spec|
        spec.name == l_name and Gem.platforms.any? do |platform|
          platform == spec.platform
        end
      end

      highest_remote_gem = matching_gems.sort_by { |spec| spec.version }.last

      if highest_remote_gem and
         l_spec.version < highest_remote_gem.version then
        result << l_name
      end
    end

    result
  end