[AccessD] sorting a list

Bobby Heid bheid at appdevgrp.com
Tue Apr 22 07:46:50 CDT 2003


Hi Susan,

For an array, if it is a small list, just use a simple Bubble sort (less
than 50 or so).  Otherwise, a QuickSort is probably your best bet.

I can give you the algorithm for these if you need them.

Bobby

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Susan Harkins
Sent: Monday, April 21, 2003 9:55 PM
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] sorting a list 


Well, this was my thought too -- but I'm not sure you need to do all that
work Drew -- at least not for what I'm doing. The list will always change --
so I'd just be dumping the collection straight into a table -- it wouldn't
even matter if there were no objects in the collection and the collection
were empty. So, you think that would be faster than an array? I'm not sure
how to sort an array -- is there a property?

Susan H.


> If the data is already in a collection, you sure can sort it with a query.
> Build a query that pulls the data from a collection.  I posted an example
of
> how to do this before.  Here's the basics.  Build a function that
retrieves
> the data from the collection by it's index.  Then build a simple table
with
> a number field.  Build a function that retrieves the count of the
> collection.  Have 2 fields in the query, the first field is the field from
> the number field table.  Put the Collection count as the criteria (<=).
> Have that function not only return the count of the collection, but have
it
> check the size of the collection against the highest value in that table.
> If the table has less 'numbers' then the collection, add enough records
> (with consecutive numbers) to bring it up to par.  Then have the second
> field in the query return the value from the collection based on the index
> retrieved from the number table.  Then hide the first field and sort the
> second.  Whalla!
>
> Drew
>
> -----Original Message-----
> From: Susan Harkins [mailto:harkins at iglou.com]
> Sent: Monday, April 21, 2003 8:03 PM
> To: accessd at databaseadvisors.com
> Subject: Re: [AccessD] sorting a list
>
>
> Can't use a query -- I'm using a For Each to loop through a collection to
> get the list. I thought about filling a table with the list, but that
seems
> worst than sorting an array. Wonder which would be quicker?
>
> Susan H.
>
>
> > I'd say the easiest way is to switch it to a query, put the 'list' in a
> > table, and have the query sort it! <grin>
> >
> > If you must stick with a list, use split to put it into array, then dump
> it
> > into a collection (or just resort the array).  Then rebuild the string.
> Of
> > course I think this is a long way of doing things!
> >
> > Drew
> >
> > -----Original Message-----
> > From: Susan Harkins [mailto:harkins at iglou.com]
> > Sent: Monday, April 21, 2003 7:52 PM
> > To: AccessD at databaseadvisors.com
> > Subject: [AccessD] sorting a list
> >
> >
> > Anyone have an easy way to sort a list or combo control's list when
> working
> > with a Value List RowSourceType?
> >
> > Susan H.
> >



More information about the AccessD mailing list