class Bundler::Index

def search_by_dependency(dependency)

def search_by_dependency(dependency)
  @cache[dependency.hash] ||= begin
    specs = @specs[dependency.name]
    wants_prerelease = dependency.version_requirements.prerelease?
    only_prerelease  = specs.all? {|spec| spec.version.prerelease? }
    found = specs.select { |spec| dependency =~ spec }
    unless wants_prerelease || only_prerelease
      found.reject! { |spec| spec.version.prerelease? }
    end
    found.sort_by {|s| [s.version, s.platform.to_s == 'ruby' ? "\0" : s.platform.to_s] }
  end
end