Sorting a Memory File

A function is available to sort the contents of a memory file alphabetically. Sorting can be done in one of three ways:

The function that sorts a memory file is the memory file sort function, mf_sort():

int mf_sort(kwdp, mfp)
 
UCHAR *kwdp;    
/* Keyword section to sort or NULLP
*/
MFILEPTR mfp;
/* Memory file to sort all or part of
*/

If you specify a keyword in the function call, only that section marked by the keyword is sorted. If you specify a NULLP, mf_sort() will either:

If you are building the memory file dynamically, by calling mf_rowrpl() or mf_rowins(), you should wait until the entire file has been built before calling mf_sort().

If your memory file uses automatic or manual keyword loading, you must sort each automatically or manually loaded keyword section just before using it. You cannot sort the entire memory file at once, since the contents are not in memory. Also, since the keyword sections are unloaded and reloaded as they are needed, you will have to sort the section each time it is used. You can avoid this situation by sorting the ASCII file on disk, so that calls to mf_sort() are not required in your code.


Home Contents Previous Next