Multiply the FLAVOR_XXX value of the Great person in UnitInfos by the matching FLAVOR_XXX of the technologies which you can currently research in TechInfos. The higher number value will be bulbed first. In the case of a tie, whichever one is listed first in the XML wins.
If the mod you are playing lists multiple FLAVOR_XXX types on a great person, you multiply each one by the matching FLAVOR_XXX value on the tech, and then add them together. Pretty sure base BtS only uses a single FLAVOR_XXX for each GP, and the value of all of them is 1, so you can just look at the FLAVOR_XXX values in the TechInfos file and sort numerically, keeping the order unchanged from the XML order in the case of a tie.
For an example:
If Great Sage has FLAVOR_SCIENCE = 3, and FLAVOR_GROWTH = 2 and FLAVOR_RELIGION = 1, and you are currently able to research Agriculture (FLAVOR_GROWTH = 5) and Writing (FLAVOR_SCIENCE = 4) and Education (FLAVOR_GROWTH = 3, FLAVOR_SCIENCE = 2), then the score you get will be:
Agriculture: 2*5 = 10
Writing: 4*3 = 12
Education: 3*2 + 2*3 = 12
Since there is a tie between Writing and Education, the one which is listed first in the XML will be the one you bulb. I believe the XML is mostly set up in alphabetical order, so that would wind up meaning Education.