If you want to store it in alphabetical order, then bubble sort is litterally the worst possible thing you could do, as that takes n^2 time and is quite slow for lots of elements. Sort the elements, using something like quicksort, merge sort, or heap sort. Then store them in a file in that sorted way, litterally one after another. This way, you can use a binary search to quickly access any element in log(n) time. So, if you have the words Apple Baby Banana Cat Dog Elephant Zebra And you're looking to see if the word dog is in your list, all you have to do is: Take the mid point, which is cat, and see if dog is before or after cat. It's after, so then take the midpoint of the remaining, which is elephant, and see if dog is before or after elephant, and it's before, so then take the midpoint of cat and elephant, which is dog, and bam, you're done. Notice how we only really examined three words to find a word in a list of 7, which is less than half of the list, and this benefit scales beautifully with larger and larger lists. Also, it's very fast to do because all you have to do is a few very simplistic calculations over and over again in a loop, and bam you're done. Anyways, I hope this helps a bit. It's important to note that you shouldn't do any of this if you don't have to; for example, if vb6 offers some sort of hash structure than you can simply use, and then all you have to do is write out and read back in the hash. Take care, Sina -----Original Message----- From: programmingblind-bounce@xxxxxxxxxxxxx [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Steven Hicks Sent: Monday, September 17, 2007 8:50 AM To: programmingblind@xxxxxxxxxxxxx Subject: Visual Basic 6 File Sorting Hello friends, tricky question here, not sure if anyone can point me in the right direction? I have a random access file which I would like to sort in to alphabetical order, does anyone know where I could make a start from here? Would I need to load all the entries in to an eray then sort them or even perform some sort of bubble sort (remembered from my college days :-). Many thanks in anticipation for any help. Steve. --------------------------------------------------------------------- - - - - - - The information in this e-mail and any attachments is confidential and is intended for the attention and use of the named addressee(s). It must not be disclosed to any other person without our authority. If you are not the intended recipient, or a person responsible for delivering it to the intended recipient or are aware that this e-mail has been sent to you in error, you are not authorised to and must not disclose, copy, distribute, or retain this message or any part of it. We sweep all outgoing messages for the presence of computer viruses. However, we cannot accept any responsibility for any loss or damage to your systems due to viruses or malicious code not detected. The statements and opinions expressed in this message are those of the author and do not necessarily reflect those of the organisations within the Cornwall & Isles of Scilly Health Community. This email may be disclosed under the Freedom of Information Act 2000 or the Environmental Information Regulations 2004. --------------------------------------------------------------------- - - - - - - __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind