 
 			<cfset basQual = "">
 			<cfset mapurl="">
-			<cfset basOrder = "ORDER BY count(#session.flatTableName#.cat_num) DESC">
+			<cfset basOrder = "ORDER BY #orderby# DESC">
 			<cfinclude template="includes/SearchSql.cfm">
 			<cfset SqlString = "#basSelect# #basFrom# #basJoin# #basWhere# #basQual# #basGroup# #basOrder#">
 			<cfquery name="getGraph" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">

							<option value="family">Specimens by Family</option>
							<option value="phylorder">Specimens by Order</option>
							<option value="year">Specimens by Year</option>
						</select>
					</td>
				</tr>

				<tr>
					<td><strong>Chart Settings</strong></td>
					<td><strong>Chart Data</strong><sup>1</sup></td>
					<td><strong>OrderBy</strong><sup>1</sup></td>
				</tr>
				<tr>
					<td valign="top">
