Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Sorting Phonebook entries onto the EEPROM...

Status
Not open for further replies.

GraveYard_Killer

New Member
how do i sort entries on the eeprom 24c32 using HC9s08rd32 running @ 5MHz bus frequency? i have 50 name entries. each entry have 24 character length names. i just need the 3 first letters to sort everything. what is the best sorting method? i tried using bubble sort but its too slow when the entry becomes larger and larger...

for this kind of situation what is the best sorting method? i prefer a method that uses minimal write as well sa pointer system of sorting things out and uses minimal memory as well.
 
Have a look at this site : **broken link removed**

It has visual animations (Java applets) of a lot of sort algorithms, along with sources for all of them.

I tend to use a quick sort most of the time, but have never implemented it in a resource-deprived environment like a microcontroller.! I think I'd try to encode the first 3 letters and the EEPROM address of each entry into as few bytes as possible (ideally one byte!) and sort that in RAM, then read and write each entry in EEPROM once. But like I said, I've never done it, so there might be a better solution. Have you searched the forums and checked http://www.piclist.com?
 
BTW, if you are doing a standard phonebook application, you really only need to insert each new entries at the right place in the list... obviously, you still need to implement a sort algorithm if you want to let the user modify the sort order i.e. a toggle between descending and ascending order for example.
 
For static memory, I usually maintain an array of pointers (for EEPROM case, array of indexes) for manipulation, be it for linked lists/stacks/queues, or sorting. Data is stored in a continuous raw data dump.
 
You could try parsing the entries, much like Apple Computer did with their Applesoft BASIC-in-ROM back in 1980s. For instance, you could assign one byte for a surname or title, another for an address or region, and a third byte for a phone prefix ( not area code). My magazine file program is written in 6502 code, and is two programs working together. The magazine "block" is moved as it is saved, and titles are saved alphabetically.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top