Re: Sorting a Collection by a certain field



The problem is that I will cycle through each 'day' very quickly in
the code, so there isn't a chance to manually compact it. it could go
through 100 'days', which means deleting, appending, and sorting the
table 100 times. So I wondered if there is a more eligant solution
than a static table.


On Oct 31, 2:38 pm, ashwin <ash...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I would go with a permanent table until you're satisfied with the solution
-you can always experiment later. If bloat is a concern, you can tell Access
to compact itself upon closing in Tools|Option|General|Compact on Close.

--
ashwin



"mpf...@xxxxxxxxxxx" wrote:
I have a question about the best way to sort a collection in VB. My
actual use is complicated so I've simplified it with the following
fake example:

I have created a class called "Person" in VB in an MS Access program.
As part of my code, I create a collection (called 'myRoom') of several
'Person' instances. One of the Person's properties is "wealth".
Every "day" in the program I want to sort the group of people in
"myRoom" by "wealth" to find who the 5 richest people are to run a few
functions on those people.

I can think of a few ways to do this, which would be best?

1) Some how sort the collection by the 'wealth' property. As best as
I can tell, there is no built in 'sort collection' function, so this
may not be possible.

2) Create a virtual temporary table in the visual basic code (dao
probably?) have one field being the person's location in the
collection, the other field being their wealth. As I cycle through
each person, add them to that table, then at the end, sort the table
and return the top 5 records. Run the function on those 5 people

3) Same as above but with a permanent table: Have a permanent table
in access with the same fields as above, first delete any existing
records in this 'PersonSortTable', then cycle through each person and
add them to the list, then sort the table and create a query to kick
out the top 5. Run the function on those 5 people

I'm not sure which way would be best. Would creating a permanent
table, deleting and appending data create a large bloat problem in the
database? Does a table that exists only in the visual basic code make
there be less bloat? Is there another option I'm missing.

Thanks to all,- Hide quoted text -

- Show quoted text -


.



Relevant Pages

  • RE: Sorting a Collection by a certain field
    ... I would go with a permanent table until you’re satisfied with the solution ... If bloat is a concern, ... I can tell, there is no built in 'sort collection' function, so this ... As I cycle through ...
    (microsoft.public.access.modulesdaovba)
  • One more "strlen" - was: Note to Chuck Crayne
    ... optimize strlen to shave one cycle off it, and you distribute your library to 1000 users, and they each write a program that uses strlen 1000 times, and distribute it to 1000 end-users, and they each run it ... We would of course only do strlen once per string, so we have to imagine we've got a lot of strings being thrown at us. ... When I click on the little hieroglyph to "sort by thread" instead of "sort by date", it takes - by wall clock - approximately a minute and fifteen seconds to complete. ... A better approach would be to keep a running index table for every column the user can sort by and every index table should be updated every time Thunderbird recieves an email/post...this way, the click on the glyph merrly selects which index table to use when picking what message headings to show in the window -- no need to run no freak'n algo. ...
    (alt.lang.asm)
  • Re: Note to Chuck Crayne
    ... know machine/assembly language, so you know what code you want to produce, and... ... you can produce HLL code that's "as good as" what you'd produce by any other means. ... optimize strlen to shave one cycle off it, and you distribute your library to 1000 users, and they each write a program that uses strlen 1000 times, and distribute it to 1000 end-users, and they each run it ... When I click on the little hieroglyph to "sort by thread" instead of "sort by date", it takes - by wall clock - approximately a minute and fifteen seconds to complete. ...
    (alt.lang.asm)
  • Re: OT: Cyclisti opinions sought
    ... one because I really want a hobby and as the last cycle I owned was a ... MTB at that sort of price because you'll destroy the ... floppy forks they put on cheap bikes. ...
    (uk.rec.motorcycles)
  • Re: A truely BIJECTIVE BWT is here!
    ... Each cycle in my way is unique. ... Given strings from ... separte cycles are different the compare function need only ... You could sort each cycle indepently and then merge the results ...
    (comp.compression)