realbasic-nug
[Top] [All Lists]

Re: Suggestions for Comparing Data

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Suggestions for Comparing Data
From: Charles Yeomans <charles at declareSub dot com>
Date: Tue, 30 Oct 2007 19:54:20 -0400
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <4727C089 dot 70101 at stny dot rr dot com>
On Oct 30, 2007, at 7:38 PM, Tom Russell wrote:

> Hi,
>
> I have some strings and want to take the whole list of them, find all
> the duplicates and keep count of each set of duplicates and then  
> show in
> ascending order the top 10 items found.
>
> Example:
>
> 25 MyText
> 21 YourText
> 18 TheText
> 15 Text
> 15 SomeText
>
> and so forth.
>
> Im looking for suggestions and ideas. Im toying with a dictionary  
> right now.


Add the list elements to a Dictionary as follows.

Sub Add(s as String, d as Dictionary)
   if d.HasKey(s) then
     d.Value(s) = d.Value(s).IntegerValue + 1
   else
     d.Value(s) = 1
   end if
End Sub

Then copy the keys and the values to corresponding arrays and use  
SortWith.

Charles Yeomans
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>