I've been searching since last night and couldn't come up with anything solid, but maybe someone here (that has had CompSci classes
) could point me in the right direction. What I am trying to do is this:
In the Palantir PDB Creator, I import all the tracks from the .csv file generated from Emplode/Jemplode. I then sort these tracks by the following values: Artist, Year, Source, Track, Title. I sort the text fields (currently) using a Collator object in Java, which uses the user's locale to determine accented characters' sort order. Then I generate the .pdb file which stores the Artist names in order along with all the tracks.
On the Palm device with Palantir, I am trying to implement a binary search through all the Artist records to scroll the Artist view to the right artist as a user enters characters in a search field. This was going well until I realized that the StrCaselessCompare function of the Palm will not compare strings with special characters in the same way as my java.text.Collator function.
I realized that I would have to write my own search function for the Palm. My question is: what's the best way to do this?
In Java, I can specify the sort order by creating a java.text.RuleBasedCollator, which takes as an argument a string representing a sort order for characters. This string would basically look something like this: a,A < b,B < c,C < d,D < eeE (with the middle e being an accented e). I could pass the RuleBasedCollator the sort order of the Palm device, but the Palm is annoying because it sorts spaces after other text characters. It would sort:
Alessandro Safini
Al Green
A Flock Of Seagulls
and I want it to sort:
A Flock Of Seagulls
Al Green
Alessandro Safini
I was thinking of making a hash table and weighting every character, but I'm not sure if there is an algorithm for sorting based upon a set of rules already existing and I don't know how to search for it. If there was, it would be easy for me to implement in both Java and Palm gcc.