Results 1 to 2 of 2

Thread: Sorting Counting Output

  1. #1

    Thread Starter
    Hyperactive Member Art W.'s Avatar
    Join Date
    Apr 2002
    Location
    In My Own Little World, But that’s OK because they know me there!
    Posts
    271

    Cool Sorting Counting Output

    Hello Everyone:

    I am trying to sort around 3 million results that are numbers (int) between 1 and 100. I want to know which number in the record set appears the most often, and continue sorting the results until all the numbers are ranked with the one that is in the set most often at the top and sorted downward.

    I am not sure what my next step is, please list all the steps you think I should use. Can I insert an Excel table in my program?

    Thanks

    Art
    SLEEP: A Totally Inadequate Substation For Caffeine!

  2. #2
    Banned
    Join Date
    Aug 2009
    Posts
    33

    Re: Sorting Counting Output

    example:
    'If your data were saved in Num() array;
    dim hs as new hashtable
    for i as integer=0 to 3000000-1
    if not hs.containkey(num(i)) then hs.add(num(i),0)
    hs(num(i).value = ctype(hs(num(i)).value, integer)+1
    next
    dim ary as new arraylist
    for each de in hs
    if ctype(de.value)>0 then ary.add(de.key)
    next
    ary.sort()

    'output
    dim outputStr as new stringbuilder()
    for i as integer=0 to ary.length-1
    outputStr.append(ary(i).tostring() & " : " & ctype(hs(ary(i)).value, integer) & " records" & controlchars.cr)
    next

    ---------------------------
    Sabrina Gage
    Last edited by si_the_geek; Apr 7th, 2010 at 05:27 PM. Reason: removed advertising link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width