Terms with same frequency are now sorted by their display name.
This makes a pretty display and improves our regression test because
qsort is not a stable sort.
static int compare(const void *s1, const void *s2)
{
- struct termlist_score **p1 = (struct termlist_score**) s1, **p2 = (struct termlist_score **) s2;
- return (*p2)->frequency - (*p1)->frequency;
+ struct termlist_score **p1 = (struct termlist_score **) s1;
+ struct termlist_score **p2 = (struct termlist_score **) s2;
+ int d = (*p2)->frequency - (*p1)->frequency;
+ if (d)
+ return d;
+ return strcmp((*p1)->display_term, (*p2)->display_term);
}
struct termlist_score **termlist_highscore(struct termlist *tl, int *len)
</list>
<list name="author">
<term><name>Jack Collins</name><frequency>2</frequency></term>
+<term><name>Englund, Carl R</name><frequency>1</frequency></term>
<term><name>Mairs, John W</name><frequency>1</frequency></term>
<term><name>Wood, Helen M</name><frequency>1</frequency></term>
-<term><name>Englund, Carl R</name><frequency>1</frequency></term>
</list>
<list name="subject">
-<term><name>Radioisotope scanning</name><frequency>1</frequency></term>
-<term><name>Scintillation cameras</name><frequency>1</frequency></term>
-<term><name>Imaging systems in medicine</name><frequency>1</frequency></term>
-<term><name>Bible. O.T</name><frequency>1</frequency></term>
<term><name>Bible</name><frequency>1</frequency></term>
+<term><name>Bible. O.T</name><frequency>1</frequency></term>
<term><name>Cartography</name><frequency>1</frequency></term>
-<term><name>Puget Sound region (Wash.)</name><frequency>1</frequency></term>
-<term><name>Tomography</name><frequency>1</frequency></term>
-<term><name>Optical pattern recognition</name><frequency>1</frequency></term>
<term><name>Computers</name><frequency>1</frequency></term>
+<term><name>Imaging systems in medicine</name><frequency>1</frequency></term>
+<term><name>Optical pattern recognition</name><frequency>1</frequency></term>
+<term><name>Puget Sound region (Wash.)</name><frequency>1</frequency></term>
+<term><name>Radioisotope scanning</name><frequency>1</frequency></term>
<term><name>Railroads</name><frequency>1</frequency></term>
+<term><name>Scintillation cameras</name><frequency>1</frequency></term>
+<term><name>Tomography</name><frequency>1</frequency></term>
</list>
<list name="date">
<term><name>date0</name><frequency>100</frequency></term>
<term><name>Mairs, John W</name><frequency>1</frequency></term>
</list>
<list name="subject">
-<term><name>Radioisotope scanning</name><frequency>1</frequency></term>
-<term><name>Scintillation cameras</name><frequency>1</frequency></term>
-<term><name>Imaging systems in medicine</name><frequency>1</frequency></term>
-<term><name>Bible. O.T</name><frequency>1</frequency></term>
<term><name>Bible</name><frequency>1</frequency></term>
+<term><name>Bible. O.T</name><frequency>1</frequency></term>
<term><name>Cartography</name><frequency>1</frequency></term>
+<term><name>Imaging systems in medicine</name><frequency>1</frequency></term>
+<term><name>Optical pattern recognition</name><frequency>1</frequency></term>
<term><name>Puget Sound region (Wash.)</name><frequency>1</frequency></term>
+<term><name>Radioisotope scanning</name><frequency>1</frequency></term>
+<term><name>Scintillation cameras</name><frequency>1</frequency></term>
<term><name>Tomography</name><frequency>1</frequency></term>
-<term><name>Optical pattern recognition</name><frequency>1</frequency></term>
</list>
<list name="date">
<term><name>1974</name><frequency>2</frequency></term>
<term><name>1977</name><frequency>2</frequency></term>
-<term><name>1980</name><frequency>1</frequency></term>
<term><name>1973</name><frequency>1</frequency></term>
+<term><name>1980</name><frequency>1</frequency></term>
</list>
<list name="medium">
</list>
<activeclients>0</activeclients>
<list name="author">
<term><name>Jack Collins</name><frequency>2</frequency></term>
+<term><name>Englund, Carl R.</name><frequency>1</frequency></term>
<term><name>Mairs, John W.</name><frequency>1</frequency></term>
<term><name>Wood, Helen M.</name><frequency>1</frequency></term>
-<term><name>Englund, Carl R.</name><frequency>1</frequency></term>
</list>
<list name="subject">
-<term><name>Radioisotope Scanning</name><frequency>1</frequency></term>
-<term><name>Scintillation Cameras</name><frequency>1</frequency></term>
-<term><name>Imaging Systems In Medicine</name><frequency>1</frequency></term>
<term><name>Cartography</name><frequency>1</frequency></term>
-<term><name>Tomography</name><frequency>1</frequency></term>
-<term><name>Optical Pattern Recognition</name><frequency>1</frequency></term>
+<term><name>Community Colleges</name><frequency>1</frequency></term>
<term><name>Computers</name><frequency>1</frequency></term>
+<term><name>Imaging Systems In Medicine</name><frequency>1</frequency></term>
+<term><name>Optical Pattern Recognition</name><frequency>1</frequency></term>
+<term><name>Radioisotope Scanning</name><frequency>1</frequency></term>
<term><name>Railroads</name><frequency>1</frequency></term>
+<term><name>Scintillation Cameras</name><frequency>1</frequency></term>
+<term><name>Tomography</name><frequency>1</frequency></term>
<term><name>Universities And Colleges</name><frequency>1</frequency></term>
-<term><name>Community Colleges</name><frequency>1</frequency></term>
</list>
</termlist>
<term><name>Water quality management</name><frequency>11</frequency></term>
<term><name>Water conservation</name><frequency>9</frequency></term>
<term><name>Drinking water</name><frequency>7</frequency></term>
-<term><name>Water use</name><frequency>6</frequency></term>
<term><name>Water rights</name><frequency>6</frequency></term>
+<term><name>Water use</name><frequency>6</frequency></term>
<term><name>Groundwater</name><frequency>4</frequency></term>
<term><name>Hydrology</name><frequency>3</frequency></term>
-<term><name>Water supply</name><frequency>3</frequency></term>
+<term><name>Nutrient pollution of water</name><frequency>3</frequency></term>
+<term><name>Purification of</name><frequency>3</frequency></term>
<term><name>Rural</name><frequency>3</frequency></term>
-<term><name>Water-supply engineering</name><frequency>3</frequency></term>
<term><name>Water harvesting</name><frequency>3</frequency></term>
</list>
<list name="author">
<term><name>Baker, M. N</name><frequency>2</frequency></term>
-<term><name>Hochschwender, Ted</name><frequency>1</frequency></term>
+<term><name>Ambrose, David</name><frequency>1</frequency></term>
+<term><name>Bauer, Steve</name><frequency>1</frequency></term>
+<term><name>Bryan, Michelle</name><frequency>1</frequency></term>
<term><name>Davis, Floyd</name><frequency>1</frequency></term>
<term><name>De Villiers, Marq</name><frequency>1</frequency></term>
-<term><name>Majeed, Abdul</name><frequency>1</frequency></term>
+<term><name>Dibdin, William Joseph</name><frequency>1</frequency></term>
+<term><name>Faeth, Paul</name><frequency>1</frequency></term>
+<term><name>Farnham, Henry P</name><frequency>1</frequency></term>
<term><name>Fisher, D. E</name><frequency>1</frequency></term>
-<term><name>Thresh, John Clough</name><frequency>1</frequency></term>
-<term><name>Glover, David</name><frequency>1</frequency></term>
<term><name>Frey, Hans</name><frequency>1</frequency></term>
-<term><name>Ravi, Rājeśa</name><frequency>1</frequency></term>
-<term><name>Sherk, George William</name><frequency>1</frequency></term>
-<term><name>Faeth, Paul</name><frequency>1</frequency></term>
-<term><name>Bryan, Michelle</name><frequency>1</frequency></term>
-<term><name>Powell, J. M</name><frequency>1</frequency></term>
-<term><name>Shade, Patricia J</name><frequency>1</frequency></term>
+<term><name>Gingerich, Stephen B</name><frequency>1</frequency></term>
+<term><name>Glover, David</name><frequency>1</frequency></term>
+<term><name>Grant, Pamela</name><frequency>1</frequency></term>
+<term><name>Hochschwender, Ted</name><frequency>1</frequency></term>
</list>
<list name="date">
<term><name>2000</name><frequency>32</frequency></term>
<term><name>1999</name><frequency>29</frequency></term>
<term><name>1998</name><frequency>6</frequency></term>
<term><name>1997</name><frequency>4</frequency></term>
-<term><name>2001</name><frequency>3</frequency></term>
<term><name>1996</name><frequency>3</frequency></term>
+<term><name>2001</name><frequency>3</frequency></term>
+<term><name>1896</name><frequency>2</frequency></term>
<term><name>1897</name><frequency>2</frequency></term>
<term><name>1898</name><frequency>2</frequency></term>
<term><name>1899</name><frequency>2</frequency></term>
<term><name>1903</name><frequency>2</frequency></term>
-<term><name>1896</name><frequency>2</frequency></term>
-<term><name>1891</name><frequency>1</frequency></term>
-<term><name>1901</name><frequency>1</frequency></term>
+<term><name>1835</name><frequency>1</frequency></term>
+<term><name>1839</name><frequency>1</frequency></term>
+<term><name>1848</name><frequency>1</frequency></term>
<term><name>1855</name><frequency>1</frequency></term>
-<term><name>1904</name><frequency>1</frequency></term>
</list>
<list name="medium">
<term><name>book</name><frequency>99</frequency></term>