From 5c7a65c1f436e3cacf8b678499e92fd832786abf Mon Sep 17 00:00:00 2001 From: HD Moore Date: Fri, 29 Sep 2006 04:31:20 +0000 Subject: [PATCH] Sorted result list git-svn-id: file:///home/svn/framework3/trunk@3994 4d416f70-5f16-0410-b530-b9f4589650da --- data/msfweb/app/controllers/application.rb | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/data/msfweb/app/controllers/application.rb b/data/msfweb/app/controllers/application.rb index c40c8fcf74..505b069e9f 100644 --- a/data/msfweb/app/controllers/application.rb +++ b/data/msfweb/app/controllers/application.rb @@ -3,27 +3,39 @@ class ApplicationController < ActionController::Base def search_modules(mlist, terms) - res = [] + res = {} unless terms return nil end + # Match search terms mlist.each do |m| + if (terms.length == 0) + res[m.name]=m + next + end + if (m.name.downcase.index(terms.downcase)) - res << m + res[m.name]=m next end if (m.description.downcase.index(terms.downcase)) - res << m + res[m.name]=m next end end - res + # Sort the modules by name + list = [] + res.keys.sort.each do |n| + list << res[n] + end + + list end end