From 111b16aecd5c423784525806b44720b06e085992 Mon Sep 17 00:00:00 2001 From: josh Date: Sun, 9 Mar 2008 22:50:15 +0000 Subject: [PATCH] implemented search result sorting on client side git-svn-id: svn://anubis/gvsu@64 45c1a28c-8058-47b2-ae61-ca45b979098e --- cs654/proj1/KaZaClient.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cs654/proj1/KaZaClient.java b/cs654/proj1/KaZaClient.java index 4c0da04..b5d1c02 100644 --- a/cs654/proj1/KaZaClient.java +++ b/cs654/proj1/KaZaClient.java @@ -127,6 +127,21 @@ public class KaZaClient } } catch (Exception e) { } + + /* sort the results by the connection speed */ + Object[] arr = results.toArray(); + java.util.Arrays.sort(arr, new Comparator() { + public int compare(Object o1, Object o2) { + return ((SearchResult)o1).speed - ((SearchResult)o2).speed; + } + }); + + results = new Vector(); + for (Object o : arr) + { + results.add((SearchResult) o); + } + return results; }